osx - Git completions for alias functions -


this question has answer here:

i have few aliased functions such gb git branch , gco git checkout in .zshrc. works great when remember full branch name i'm creating, deleting, checking out, etc. however, noticed completions no longer seem work. previously,

$ git checkout m<tab> 

and autocomplete master if name of branch. now, however, following error when use:

$ gco m<tab> _git:15: parse error: condition expected: 1 

i'm not sure why occurring. appears there's possibly missing argument, i'm not sure why.

edit:

i'm setting alias git branch , git checkout in .zshrc file this:

alias gco='git checkout' alias gb='git branch' 

after little more digging around found solution same problem bash looks work zsh. after defining 2 functions __define_git_completion , __git_shortcut call __git_shortcut set alias , completion in 1 call.

__define_git_completion () { eval "     _git_$2_shortcut () {         comp_line=\"git $2\${comp_line#$1}\"         let comp_point+=$((4+${#2}-${#1}))         comp_words=(git $2 \"\${comp_words[@]:1}\")         let comp_cword+=1          local cur words cword prev         _get_comp_words_by_ref -n =: cur words cword prev         _git_$2     } " }  __git_shortcut () {     type _git_$2_shortcut &>/dev/null || __define_git_completion $1 $2     alias $1="git $2 $3"     complete -o default -o nospace -f _git_$2_shortcut $1 }  __git_shortcut  ga    add __git_shortcut  gb    branch            # use one. __git_shortcut  gba   branch -a __git_shortcut  gco   checkout          # , use one, too. __git_shortcut  gci   commit -v __git_shortcut  gcia  commit '-a -v' __git_shortcut  gd    diff __git_shortcut  gdc   diff --cached __git_shortcut  gds   diff --stat __git_shortcut  gf    fetch __git_shortcut  gl    log __git_shortcut  glp   log -p __git_shortcut  gls   log --stat 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -