Skip to content

Instantly share code, notes, and snippets.

@devshorts
Created March 1, 2015 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devshorts/ab14c8cd5f72555819aa to your computer and use it in GitHub Desktop.
Save devshorts/ab14c8cd5f72555819aa to your computer and use it in GitHub Desktop.
Sample zsh completion for git branches you aren't on
#compdef test
local arguments
_branch(){
val=()
git branch | grep -v "\*" | while read -r branch ; do
val=($val $branch)
done
}
local expl
local -a val
arguments=(
'--branch[The git branch]: :->branch'
)
case "$state" in
branch)
_branch
_wanted val expl "Branches" compadd -a val
;;
esac
_arguments $arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment