Home > Net >  Is there an autocomplete (__git_complete) for "git push origin"
Is there an autocomplete (__git_complete) for "git push origin"

Time:10-27

trying to create git alias alias gpo = "git push origin" but there doesn't seem to be a __git_complete for git push with an origin, __git_complete gpo _git_push wants to autocomplete the origin even though it's included in the alias.

CodePudding user response:

This works for me (complete references — local and remote branches, and tags):

alias gpo="git push origin"

_gpo_comp_refs() {
    __load_completion git
    local cur="${COMP_WORDS[COMP_CWORD]}"
    COMPREPLY=(`compgen -W "$(__git_refs)" -- "$cur"`)
}

complete -F _gpo_comp_refs gpo
  • Related