Contents

Bash Tab-Completion

By default Bash will complete filenames if you press the tab key. This is useful and saves typing but
doesn't take into account context. For example the first argument to the chown command
is a username not a file.

Following the steps below will give you enhanced completion, taking context into account such
as this partial list of examples:

Commands which only take directories (eg cd get only those)

Document types (eg PDF readers complete to pdf files)

Usernames and groups are supplied where appropriate (eg chown and chgrp)

Configuration

Portage Related Commands

By default, Bash tab-completion support for Portage related commands (emerge, equery, revdep-rebuild etc.) is globally enabled, but usually only the root user can use them. Unless other users are part of the portage group, enter the following commands:

Other commands

Only Bash tab-completion support for the Portage-related commands is enabled by default, but as we previously said other tools (unrar, genlop etc.; here is the full list) support this nice feature as well.

If you want to enable Bash tab-completion for the genlop command, for example, just type:

if using eselect:

# eselect bashcomp enable genlop

if using bash-completion-config:

# bash-completion-config --install genlop

Remember, for the changes to have an immediate effect, issue the following command:

# source /etc/bash/bashrc

Enabling All Completions

If you want to enable all of the installed completions you can run this command:

# for i in $(ls --color=no /usr/share/bash-completion/); do ln -s /usr/share/bash-completion/$i ~/.bash_completion.d/$i; done

Or, if you want to enable all installed completions globally, run this as root:

# for i in $(ls --color=no /usr/share/bash-completion/); do ln -s /usr/share/bash-completion/$i /etc/bash_completion.d/$i; done