Skip to content

Instantly share code, notes, and snippets.

@the-eric-kwok
Last active March 1, 2018 08:23
Show Gist options
  • Save the-eric-kwok/547ae61f75db6bc2c6a64c168e676cdf to your computer and use it in GitHub Desktop.
Save the-eric-kwok/547ae61f75db6bc2c6a64c168e676cdf to your computer and use it in GitHub Desktop.
Give you a smarter auto-complete

Debian does not come with 'bash-completion' installed and enabled.

To fix this, run (as root):

apt-get install bash-completion

Then, you have two options. You can either (1) enable it on a per-user basis for yourself, or (2) enable it globally.

If you want to enable it for just your user, edit ~/.bash_profile and ~/.bashrc - add the following:

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

To try it without logging out and back in, run:

. ~/.bashrc

Or open a new shell. Then try to use tab-completion with apt. That dot and space at the beginning (.) is the same as using the source keyword in bash, but is more portable.

If you want it to work when su'd into the root account, do the same thing in root's home directory (typically /root).

To enable it globally, do the changes from (1) in the file /etc/bash.bashrc instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment