1

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 1

2

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
Sign up to request clarification or add additional context in comments.

7 Comments

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.
@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?
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.
@Jae Surely you use bash completion but do you use the full bash-completion package? Or just git-completion.bash?
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
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.