1

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"?

2

1 Answer 1

4

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.

Not the answer you're looking for? Browse other questions tagged .