Monday, October 29, 2007

bash and tab completion of symlinks to directories

When using bash, ever wonder why you have to hit tab twice with completion when the object is a symlink to a directory?
For example:

bash-3.1$ mkdir -p a/b/c/d
bash-3.1$ ln -s a/b/c carrot
bash-3.1$ cd c<tab>arrot<tab>/

It's due to the GNU readline library. Readline has several variables that can be set to influence its behavior, including tab completion of symlinks to directory names. If you find double tapping tab annoying, the fix is trivial. Simply add these two lines to your inputrc:

set mark-directories On
set mark-symlinked-directories On

inputrc will be /etc/inputrc or your ~/.inputrc, either will work.

2 comments:

Eric Covener said...

Great tip, the trailing slash on symlinked directorys has been a pet peeve of mine for a long time!

Kristian Domagala said...

Very helpful for me too! Cheers.