How to alias 'git' to 'g' so that bash-completion rules are preserved?
Latest bash-completion upstream moved and renamed things a bit. It's now:
source /usr/share/bash-completion/completions/git
__git_complete g __git_main
Use this in recent versions of Ubuntu (e.g. 14.04, also Fedora 22+) when you encounter:
completion: function `_git' not found
during completing.
Copying and modifying opportunely from /etc/bash_completion.d/git
, add the following lines to your ~/.bashrc
:
complete -o bashdefault -o default -o nospace -F _git g 2>/dev/null \
|| complete -o default -o nospace -F _git g
In ~/.bashrc
:
alias g='git'
source /usr/share/bash-completion/completions/git
complete -o default -o nospace -F _git g
Via http://29a.ch/2013/8/9/fixing-bash-autocomplete-on-ubuntu-13-04