Advanced bash completion

The linux bash shell has great auto-completion of stuff like file names and commands. You can invoke it anytime while typing the start of a command by pressing TAB.

But some stuff dies not get auto-completed, e.g., command parameters or package names when using apt-get. You can turn advanced bash completion on to enable this. First ensure that the bash-completion package is installed:


# for SuSE:
sudo zypper in bash-completion
# for Debian-based distros like Ubuntu:
sudo apt-get install bash-completion

Find lines like the following ones in /etc/bash.bashrc or your personal version ~/.bashrc and remove the comment symbols (#) at the start of each line:


# enable bash completion in interactive shells
# if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
# fi

These lines check for the existence of the bash_completion file, and if it is found, it is loaded (this is done by the point).

Next time you log in, bash-completion will be auto-loaded. To load it now for your current session, you can just do this:


# as your user
. /usr/share/bash-completion/bash_completion

Enjoy!

Advertisements

About dfspspirit

PhD student in bioinformatics, interested in photography, level design, digital image manipulation, architecture and, of course, bioinformatics.
This entry was posted in bash, IT and computers and tagged , , , , . Bookmark the permalink.

One Response to Advanced bash completion

  1. Taye says:

    simply lost in wonder . the interiors I saw gave me the impression of viewing nonexistent objects .. .
    it all has a dreamy quality , like something transcendental seen under the influence of a strange drug , as we would say in philosophy. and all this arriving at a time when I was writing ( in my blog ,( in German ) and discovering Nonexistent Entities . I have no idea of the things said here but like a child who sees the pictures because he can’t yet read – and that was the fascination , the magic moment of landing in a nonexisting world of beautiful hallucination , a strange fascination . I couldn’t stop watching the series of wonders .that kept coming as if from another world. For reasons I canno tell , it made me sudddenly remember H. G. Well’s science fictions as ” In the days of the comet ” . He too can evoke with words some of the feeling your mysterious interiors evoked in me. It made me think of studying biology . I hope this wont be taken as an intrusion of a stranger . I have enjoyed the pictures and therefore I couldn’t have been an absolute stranger . My respect for the performance and thanks for allowing your work to be seen and wondered at . Nature , you see, is as generous as she is , letting us see all her wonders for free .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s