Created
February 6, 2012 01:18
-
-
Save underhilllabs/1748784 to your computer and use it in GitHub Desktop.
Add a Drush alias in Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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