Use Drush Autocomplete with Zsh

Update: I had the filename as drush.autocomplete.sh, but the filename should now be drush.complete.sh. Brent noticed this. The info below as been updated as such.

Brent Dunn pointed me to drush.complete.sh, which I didn't even know existed. Brent and I both wanted to give this a go in Zsh since we use oh-my-zsh, but drush.autocomplete.sh is setup for bash.

I was able to get drush autocompletes working with Zsh thanks to this stack exchange post

  1. Save drush.complete.sh to your local file system
  2. Add the following to your ~/.zshrc file
    autoload bashcompinit
    bashcompinit
    source /path/to/your/drush.complete.sh
  3. Source the changes: $ source ~/.zshrc

Now you can enjoy drush autocompletions in zsh style! For example, $ drush sql followed by tab will give you a browsable list of all the drush sql related commands.

1.%20zsh

Blog Category: 

Comments

i only had to drop "auto"

i only had to drop "auto" from the source, so it reads "drush.complete.sh" and voila! i'll be using this right away, thanks!

bashcompinit

bdone: You still may want to use bashcompinit since that is the way to have Zsh follow the complete bash spec. While Zsh is picking up the source file, it may not always work depending on implementation in the completion file.

This one is awesome, one

This one is awesome, one which I was looking for since long time!
Thanks!

Make sure you grab the raw

Make sure you grab the raw source from the github file, not save link as when you want to save the drush.complete.sh

Excellent, the only thing

Excellent, the only thing that doesn't work for me is autocomplete without a first letter for the option to insert, which is a little bit unfortunate, do you by any change know anything around that?

Not sure on that Dieter. I

Not sure on that Dieter. I can type drush and then a few characters, followed by tab and I get options. The only thing I notice is that I have to ctrl-c to start over. Backspacing doesn't reset the autocomplete.

Add new comment