How to get a colored tab completion


Is there a way to get colored output when using tab completion in a terminal? My colors are fine everywhere else so I know that I've enabled a color terminal successfully.

Using bash in Ubuntu (10.10).

Best Answer

There's no facility within Bash to color output during completion as there is in fish and zsh. One could write completion functions that output color control sequences, but you'd have to maintain copies of the proposed completions with and without color codes or strip the out when the user makes a selection since Bash uses the selection directly normally and the color codes would get in the way.

If this is an important feature for you, I would recommend that you consider using zsh.


Bash 4.3 readline adds a variable that enables color for tab completion to show different colors for executable files, directories, etc., during tab completion:


Readline in the upcoming Bash 4.4 adds a variable which enables color to indicate the matching portion of the string during tab completion.


You can see the values of these variables using

bind -v | grep color

To set them, add lines(s) to your ~/.inputrc file such as:

set colored-stats on