1
2
I have an alias
alias gi=git
Unlike git
, gi
cannot complete on subcommands, paths, branches.
How can I tell bash to "complete X as if it were Y"?
1
2
I have an alias
alias gi=git
Unlike git
, gi
cannot complete on subcommands, paths, branches.
How can I tell bash to "complete X as if it were Y"?
3
You'll probably want to add this to your .bashrc or .bash_aliases.
# load git completions
_completion_loader git
# assign git's completion function _git to gi
complete -o bashdefault -o default -o nospace -F _git gi
Alternatively you can use the following (which is pretty much equivalent):
# load git completions
. /usr/share/bash-completion/completions/git
# assign git's completion function _git to gi
__git_complete gi _git
Note, you can skip the first line (of either of the aforementioned examples) if dynamic completions are not enabled. You should probably assume it is enabled though.
6https://superuser.com/questions/436314/how-can-i-get-bash-to-perform-tab-completion-for-my-aliases ? – JohannesM – 2015-11-23T13:42:19.420
1
The answer here is better than the ones at https://superuser.com/questions/436314/how-can-i-get-bash-to-perform-tab-completion-for-my-aliases . I'm going to add it there as well.
– wisbucky – 2018-07-26T21:57:09.353