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)


2 Answers 2


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.

  • 3
    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
    Commented Jan 6, 2021 at 1:50

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-symlinked-directories on' >> ~/.inputrc
echo 'export INPUTRC=~/.inputrc' >> ~/.bashrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .