Bash Completion on Ubuntu 12.04 LTS – hit TAB to complete your command

As many of you already know, the Linux/Unix command line interface has a neat little feature, that greatly enhances the speed of executing commands (and finding files) by reducing the time it takes for one to type in the command. What it actually looks like is fairly simple, for example you would like to issue the command “gnome-commander”. To do this, hit up a terminal of some kind (if you are using a GUI, that is) and start typing “gn” – and hit TAB afterwards. What happens is, bash will complete your command until there are multiple choices available, leaving your flashing cursor just after “gnome-“. Again, hit TAB to see the possibilities, and after that hit “c” and TAB again. Now you should have “gnome-commander” written just by pushing five buttons. Seems pretty comfy, doesn’t it?

To enable bash completion under Ubuntu 12.04 LTS Precise Pangolin, just hit up a Terminal, navigate to your home directory, open .bashrc in nano and copy-paste these three lines:

if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

Save your .bashrc file, exit from your Terminal, and once you log back in voilá! Bash completion works 🙂

 

About the author

Gábor Hargitai

View all posts