17

I have a symbolic link for a directory,

e.g ln -s /tmp /xxx

Now when I type /xx and press tab key, bash would complete the line to /xxx

If I press it again it become /xxx/

Now, how can I ask bash to complete /xx to /xxx/ automatically (provided that there's only one match)

daisy
  • 53,527
  • 78
  • 236
  • 383

2 Answers2

27

Add the following line to your ~/.inputrc file:

set mark-symlinked-directories on

See "Readline Init File Syntax" in the Bash Reference Manual for more on this topic.

Warren Young
  • 71,107
  • 16
  • 178
  • 168
  • 2
    WHY have I never searched for this issue? This has been bugging me for so long! (all my personal files reside under a symlink in my home folder) – sylbru Jan 06 '21 at 01:50
1

WORKSFORME on Ubuntu 15.10. What are you on? Are you sure you are using bash and not zsh?

Maybe just maybe :

echo 'set mark-directories on' >> ~/.inputrc
echo 'export INPUTRC=~/.inputrc' >> ~/.bashrc
Law29
  • 1,136
  • 1
  • 9
  • 18
  • Mac, updated question – daisy Apr 12 '16 at 05:40
  • 2
    You have the exact opposite problem of http://unix.stackexchange.com/questions/25734/avoid-a-trailing-slash-in-bash-when-completing-a-directory-name-like-zsh?rq=1 right? – Law29 Apr 12 '16 at 05:42