If I write a zsh function like this
function git_checkout_with_selecta() {
if [[ -z $1 ]]; then
git checkout `git branch --no-merged | selecta`
else
git checkout "$@"
fi
}
alias gco='git_checkout_with_selecta'
How can I apply the same tab completions that I have for 'git checkout' to the alias for the function 'gco'?
When you hit the tab key, the system will complete the path to the Documents folder. At this point, you can add a character or two to get to a unique completion, and hit the tab key again. In zsh you can also hit the tab key repeatedly to cycle through the suggested completions.
Zsh users at times need to use a bash completion script. This is necessitated by Developers who only write bash completion scripts for their tools. On the bright side, zsh has a bash completion script compatibility mode, you have to enable it before loading a bash completion script inside . zshrc.
compdef _git gco=git-checkout
This will use the _git
completion function, and sets git-checkout
as the service/sub-command.
Something like:
compdef gco=git
If your completer triggers on git.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With