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.
1 Answer
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
7 Comments
Jae
this doesn't seem to be working for me, will get
$ gpo bash: __load_completion: command not found bash: __load_completion: command not found Though it might be something on my machine, also sorry for leaving you hanging for a few days, weekend things.phd
@Jae
__load_completion is a function from bash-completion package. If you don't use bash-completion you can remove the line from my code. On the other hand if you don't use the package what completion do you use?Jae
pretty sure i'm using bash completion and it works in other places, but not with this code for some reason, let me try to reconfigure and get back to you.
phd
@Jae Surely you use bash completion but do you use the full
bash-completion package? Or just git-completion.bash?Jae
pretty sure its just git-completion.bash, is bash-completion available for windows and if so how do I install that package. Not seeing much online that's not just git-completion.bash
|