Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Created February 6, 2012 01:18
Show Gist options
  • Save underhilllabs/1748784 to your computer and use it in GitHub Desktop.
Save underhilllabs/1748784 to your computer and use it in GitHub Desktop.
Add a Drush alias in Emacs
(defcustom drush-default-alias-file "~/.drush/aliases.drushrc.php"
"Default drush configuration directory."
:type 'string
:group 'drupal)
(defun drupal-drush-alias-add (name uri root)
"Add an alias to the drush aliases file in a buffer."
(interactive "sAlias Name: \nsURI: \nsRoot: ")
(drupal-drush-process-alias-file drush-default-alias-file name uri root))
(defun drupal-drush-process-alias-file (file name uri root)
"Read the contents of a file into a temp buffer and then do
something there."
(when (file-readable-p file)
(let (mybuffer)
(setq mybuffer (find-file file))
(goto-char (point-max))
(insert (format "$aliases['%s'] = array(\n" name))
(insert (format " 'uri' => '%s',\n" uri))
(insert (format " 'root' => '%s',\n" root))
(insert (format ");\n"))
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment