Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

when I perform an auto-completion of a bash variable an additional white space is added at the end.



$FOO" " 

I added the quotes in order to denote the white space. The problem is that some variables we use are directories and the white space is annoying, since it has to be removed and a / has to be typed. Is it somehow possible to configure a behaviour like this





cd $FO[TAB]


cd $FOO/

Best regards, Georg

share|improve this question

migrated from May 24 '13 at 20:43

This question came from our site for professional and enthusiast programmers.

You might want to see this:… –  devnull May 24 '13 at 8:19
There are several steps to consider: 1) Make $FO[TAB] complete to $FOO, 2) expand $FOO to its value, and 3) recognize that the value is a directory, and complete it with a trailing / and no space. 1) is the default, 2) can be accomplished with some readline settings and configuration. 3) is tricky, and will require at least some significant work with the programmable completion facilities. –  chepner May 24 '13 at 15:43

1 Answer 1

Better late answer than nothing...

The convenient completion directory names in variables was implemented in bash 4.3. The bash 4.3 checks whether a shell variable expands to a directory name and appends / to the word as appropriate.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.