Bash completion for Mac OS X

If your are using the Terminal application of your Apple computer running Mac OS X, try bash programmable completion. It allow you to use the TAB key more often, for example in scp: (If you are using ssh-keys.)

$ scp shell01:/etc/pa
/etc/pam.d/         /etc/pam_smb.conf   /etc/passwd
/etc/pam_pkcs11/    /etc/pango/         /etc/passwd-
$ scp shell01:/etc/pa

The steps to start using this great utility are these:

  1. Download the bash programmable completion .tar.gz file.
  2. In a Terminal on your Apple, untar it. (tar -xvf bash-completion-20060301.tar
  3. Copy the bash_completion shell-script to /etc (sudo cp bash_completion/bash_completion /etc)
  4. Add the bash complation to your login script. (echo ". /etc/bash_completion" >> ~/.profile)
  5. Start a new terminal and see the result!

Comments

Headsup. Just came across

Headsup. Just came across this and the instruction didn't work for me with bash-completion 1.3, i.e. no scp completion after copying and sourcing bash_completion. Reason being: the ssh/scp and other app-specific completions aren't part of the bash_completion script (anymore?), but split off to separate files in the completions/ subdir. Either take care of them manually (copy them to /etc/bash_completion.d/) or consider using one of fink/homebrew/macports to install bash-completion in a way that possibly takes care of all required files.

You can also get it through

You can also get it through brew (an OS X package manager):
brew install bash-completion would do it, it will output some code to add to your ~/.(bash_)profile and you're set.

Thank you. Worked great!

Thank you. Worked great!

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning [email protected]