Getting bash completion on OS X and Linux
Read time: 1 min
- Install bash-completion
on OS X:
sudo port install bash-completion
sudo apt-get install bash-completion
- Paste this in your .bashrc / .bash_profile
on OS X:
# MacPorts Bash shell command completion if [ -f /opt/local/etc/bash_completion ]; then . /opt/local/etc/bash_completion fi
or for MacPorts since version 2.1.2 on Mountain Lion:
# MacPorts Bash shell command completion if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then . /opt/local/etc/profile.d/bash_completion.sh fi
or for MacPorts with newer versions of git:
if [ -f /opt/local/share/git-core/git-prompt.sh ]; then . /opt/local/share/git-core/git-prompt.sh fi
Note: Bash 4.1 or higher is required by bash_completion.sh. If completion doesn’t work try
echo $BASH_VERSION to see if that’s the issue. If so, enter MacPorts bash by typing bash and try git completion again.
# enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if [ -f /etc/bash_completion ] && ! shopt -oq posix; then . /etc/bash_completion fi
Thanks for reading.
Got some words you want to share? Tell me!