Possible Duplicate:
Tab-completion with directories/links

when I've a symlink foo linking to a directory bar/ and I start typing f and hit tab, it completes to foo but I'd like to complete it to foo/ so I can immediately add the next character for further completes. How can I do that?


2 Answers 2


Enable the mark-symlinked-directories option for readline.

  1. Edit ~/.inputrc:

    $include /etc/inputrc
    set mark-symlinked-directories on
  2. Press C-x, C-r to reload the settings.

See section READLINE in the manual page of bash for further documentation.

For those who do not wish to add another dot file, you can also add this line to your ~/.bashrc:

bind 'set mark-symlinked-directories on'
  • Thank you so much, I've been dealing with the differences between OSX (defaults to on) and Linux (defaults to off) for months, and I finally got fed up enough to google it! You're my new hero. :) Aug 7, 2013 at 0:56
  • 3
    On some terminals C-x, C-r didn't work for me so I use bind -f ~/.inputrc
    – blockloop
    Aug 1, 2014 at 20:05
  • 3
    This shows the power of stackexchange combined with a simple answer and well-formulated question, answered my question in first attempt, got here via google, thanks. :)
    – DusteD
    Oct 7, 2014 at 13:57
  • 1
    what is this line $include /etc/inputrc for?
    – razzak
    Dec 9, 2015 at 17:30
  • 1
    Would there be a problem with placing set mark-symlinked-directories on in the `/etc/inputrc' file itself? Sep 4, 2022 at 7:58

I don't know if you can do it exactly as you've described, but if you hit tab twice, it should complete the exapansion.

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