If you can find out the completion function used by the original command, you can assign it to the alias using complete -F
.
For example, on my ubuntu box, the completion function used by git checkout
is _git_checkout
(found in /etc/bash_complete.d/git
).
Example
Before running complete -F
:
[me@home]$ git checkout <TAB><TAB>
HEAD master origin/HEAD origin/master
[me@home]$ alias go="git checkout"
[me@home]$$ go <TAB><TAB>
.git/ precommit_config.py README.md SvnSentinel/
.gitignore precommit.py startcommit.py tests/
After:
[me@home]$$ complete -F _git_checkout go
[me@home]$$ go <TAB><TAB>
HEAD master origin/HEAD origin/master