Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make completions available in zsh #518

Martin1982 opened this issue Jun 13, 2013 · 9 comments

Make completions available in zsh #518

Martin1982 opened this issue Jun 13, 2013 · 9 comments


Copy link

@Martin1982 Martin1982 commented Jun 13, 2013

I'm using oh-my-zsh as my default command line tool, when adding the completion to my .zshrc the command is not recognized.

/Users/myusername/.composer/vendor/wp-cli/wp-cli/utils/wp-completion.bash:21: command not found: complete

It would be a nice feature if zsh is supported as well.

Copy link

@scribu scribu commented Jun 13, 2013

Yes, it would be nice.

Copy link

@scribu scribu commented Jun 19, 2013

It seems that ZSH can read the existing bash completion functions:

Going to update the instructions on

Copy link

@ghost ghost commented Jul 13, 2013

Can anyone confirm this? I updated my .zshrc with the lines from the updated instructions in 6c919d6f08823db6bf39a5da7dab4c5559fe7d27 and am still getting this error when opening a new shell:

complete:13: command not found: compdef

Using zsh 5.0.2 on OS X 10.8.4 with Oh-My-ZSH installed as well.

The line that seems to trigger it is the call to the auto-completions file:
source $HOME/.composer/vendor/wp-cli/wp-cli/utils/wp-completion.bash

Copy link

@ghost ghost commented Jul 13, 2013

Seems to be a location issue. If I moved it to the very end of my .zshrc file it works fine now.

Copy link

@rezzafr33 rezzafr33 commented Nov 17, 2014

I put this line before sourcing bash_completion:
autoload -U +X bashcompinit && bashcompinit

bashcompinit command will create complete function for the Z shell.

Copy link

@fjarrett fjarrett commented Oct 10, 2015

Thanks, it worked for me!

For anyone else using VVV this is what I did:

$ vagrant ssh
$ echo "autoload -U +X bashcompinit && bashcompinit" >> ~/.zshrc
$ echo "source /srv/www/wp-cli/utils/wp-completion.bash" >> ~/.zshrc
$ source ~/.zshrc
Copy link

@jorgeorpinel jorgeorpinel commented Mar 18, 2016

For anyone who needs this without having installed WP-CLI via Composer, you can set it up manually by copying the contents of master/utils/wp-completion.bash to a local ~/wp-completion.bash file, and adding these lines to .zshrc (or .zshprofile I assume, not sure, I use oh-my-shell):

# WP-CLI Bash completions
autoload bashcompinit
source $HOME/wp-completition.bash
Copy link

@aaronsmulktis aaronsmulktis commented May 24, 2016

you da man @rezzafr33

Copy link

@mlopezcoria mlopezcoria commented Jul 12, 2017

Thank you very much for your help @jorgeorpinel ! I made a script to install the completion into zsh (OhMyZsh!). Maybe it can be useful for anyone:

#! /bin/bash

printf "Downloading WP-CLI...\n"
wget -O ~/wp-cli.phar

printf "\nInstalling \'wp\' command...\n"
chmod +x ~/wp-cli.phar
sudo mv ~/wp-cli.phar /usr/local/bin/wp

printf "\nDownloading WP-Cli zsh completion...\n"
wget -O ~/wp-completion.bash
printf '\n# WP-CLI Bash completions\nautoload bashcompinit\nbashcompinit\nsource ~/wp-completion.bash' >> ~/.zshrc
source ~/.zshrc

printf "\nWP-CLI installation done!\n"


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants