Skip to content

Instantly share code, notes, and snippets.

@dhaley
Last active December 17, 2015 23:19
Show Gist options
  • Save dhaley/5688333 to your computer and use it in GitHub Desktop.
Save dhaley/5688333 to your computer and use it in GitHub Desktop.
drush eshell completion
;;**** Drush Completion
(defun pcmpl-drush-commands ()
"Return the most common drush commands by parsing the drush output."
(with-temp-buffer
(call-process-shell-command "drush" nil (current-buffer) nil
"--early=includes/complete.inc")
(goto-char 0)
(let (commands)
(while (re-search-forward
"^[[:blank:]]*\\([@]?[[:word:]-.]+\\)"
nil t)
(push (match-string 1) commands))
(sort commands #'string<))))
(pcmpl-drush-commands)
(defconst pcmpl-drush-commands (pcmpl-drush-commands)
"List of `drush' commands.")
(defun pcomplete/drush ()
"Completion for `drush'."
;; Completion for the command argument.
(pcomplete-here* pcmpl-drush-commands)
(cond
((pcomplete-match "help" 1)
(pcomplete-here* pcmpl-drush-commands))
(t
(while (pcomplete-here (pcomplete-entries))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment