How To Add Bash Completion In Debian

Author: Stephan Jau
Revision: v1.0
Last Change: April 26 2009

Introduction

Bash completion is a useful tool for completion of file paths, commands etc. By default it is enabled on Ubuntu but not on Debian. With two simple steps it can also be enabled on Debian.

 

1. Install bash-completion

First of all we need the install the according package:

apt-get install bash-completion

 

2. Add it to the bash profile

Either edit the ~/.bash_profile file to enable it only for a given user or edit /etc/profile to add it system-wide. Add the following code:

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

 

3. Try it

In order for it to work you have to log out and relogin and then you can make use of bash completion the usual way. E.g. issue:

apt-g

and then press the TAB key once and the command will be completed to apt-get. Or issue this:

apt

and then press TAB key twice. You can also try with

apt-get install apa

and then press TAB key once to complete as far as possible and a second time to list all options.

Share this page:

9 Comment(s)

Add comment

Comments

From: Alex

I've just installed my Debian and the completion works out-of-the-box for all options and filenames. The bash_completion package was installed by default.

From:

did you install a minimal system or just default server?

From: Stuart

Only bash completion for filenames and directories is enabled by default -- bash completion for options and restricting filenames requires the installation of the bash-completion package from lenny onwards.

The completion of "apt-get i" to "apt-get install" will work only with the bash-completion package installed... unless you have a file called "install" in that directory.

   apt-cache show bash-completion

(read first, reply second)

From: nadavkav

as far as i can remember it was always ON :-)

but it is always good to know how to turn it off too.

thanks !

From: Russ

Why would you install an external package? I mean, the completion support is already there. You uncomment the bash completion part in /etc/bash.bashrc and then just source this file in /etc/profile

From: Piki

Ekhm? I have always thought that the completion system was always ON in Debian? I have never needed to turn it on?

From: Anonymous

Hi, please, check out bash completion script for clearcase UNIX tools. Cheers, Jan.

http://jan.tomka.name/project/clearcase-completion-bash

From: Alain

Good evening

I followed the above instructions and copy and paste the informations as asked.

I logged out and i am now unable to logon back

I use a Debian 8.2 upgradeg to 8.5

Regards

 

From: Raymond

Same here. Unable to log back in. Anybody got a solution?