Skip to content

Instantly share code, notes, and snippets.

@efatsi
Created September 18, 2012 17:51
Show Gist options
  • Save efatsi/3744621 to your computer and use it in GitHub Desktop.
Save efatsi/3744621 to your computer and use it in GitHub Desktop.
Git completion with aliases
######## git_completion.bash ######## (from Chris J. file suggestion)
complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
|| complete -o default -o nospace -F _git git
## Just added this line below, it works
complete -o default -o nospace -F _git_checkout gch
######## /usr/local/etc/bash_completion.d/git_completion.bash ######## (from brew install bash-completion)
__git_complete ()
{
local wrapper="__git_wrap${2}"
eval "$wrapper () { __git_func_wrap $2 ; }"
complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
|| complete -o default -o nospace -F $wrapper $1
## This does NOT work, error displayed below
complete -o bashdefault -o default -o nospace -F _git_checkout gch 2>/dev/null \
|| complete -o default -o nospace -F _git_checkout gch
}
$ gch ma(tab) ...
$ gch ma-bash: [: 1: unary operator expected
-bash: [: 1: unary operator expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment