I'm using go
as a simple bash alias for git checkout branchname
. The thing that I miss is the autocomplete feature that works with the full git checkout branchna...
command, but not in the alias.
Is there a way to instruct Bash to "inherit" the autocomplete "driver" for another command?
Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.
After using complete -F
:
complete -F _git_checkout go
Tabbing after go
may result in:
bash: [: 1: unary operator expected
complete
, use __git_complete
This is git bash completion's built-in function for this purpose.
After declaring your alias, bind the correct auto-complete function to it:
# Main git completions (prior to git 2.30, you an use _git instead of __git_main) alias g="git" __git_complete g __git_main alias go="git checkout" __git_complete go _git_checkout alias gp="git push" __git_complete gp _git_push
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With