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

Closed
Martin1982 opened this Issue Jun 13, 2013 · 9 comments

Comments

8 participants
@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.

@scribu

This comment has been minimized.

Member

scribu commented Jun 13, 2013

Yes, it would be nice.

@scribu

This comment has been minimized.

Member

scribu commented Jun 19, 2013

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

http://stackoverflow.com/a/8492043/97998

Going to update the instructions on wp-cli.org

@ryanduff

This comment has been minimized.

Contributor

ryanduff 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

@ryanduff

This comment has been minimized.

Contributor

ryanduff 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.

@rezzafr33

This comment has been minimized.

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.
croach/nvm@205117b

@fjarrett

This comment has been minimized.

Contributor

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
@jorgeorpinel

This comment has been minimized.

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
bashcompinit
source $HOME/wp-completition.bash
@aaronsmulktis

This comment has been minimized.

aaronsmulktis commented May 24, 2016

you da man @rezzafr33

@mlopezcoria

This comment has been minimized.

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 https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/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 https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/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"

Regards!

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