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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.