7

I use symlinks a lot and pretty much linked my whole home directory into a folder .other or .dotfiles. When I'm im my home directory and try to got into the folder .config/, its actually a symbolic link to .other/.config/.
If .config/ was a normal directory I could just type cd .con and hit tab. Bash would automatically expand it to .config/ (as long as there are no other files/directories starting with .con). Unfortunately bash has this little hurdle, when navigating through symlinks: Bash only expands to .config (not .config/) and I have to hit tab another time to add the / (to got further).
This is just minor, but is there a possibility to get bash to add a slash even after symlink expansion?

1 Answer 1

14

Set the mark-symlinked-directories readline option.

The usual way to do this is to edit ~/.inputrc, put

set mark-symlinked-directories on

in there, then start a new bash shell (or press Ctrl+X Ctrl+R to reload your readline settings).

Less commonly, you could also put it straight in your ~/.bashrc like this

bind 'set mark-symlinked-directories on'
4
  • Wow, thank you! Is the ~/.inputrc a part of bash or where does it belong to? Can I add it to my ~/.bash_profile instead? Commented Jan 26, 2016 at 22:40
  • Ok, it doesn't work in ~/.bash_profile. No problem just another file for .dotfiles... Commented Jan 26, 2016 at 22:50
  • You can actually do bind 'set mark-symlinked-directories on' in any bash config file (or in the bash shell) if you prefer.
    – Mikel
    Commented Jan 26, 2016 at 22:51
  • Thank you so much. Would be a little unpleasant to create a new file for just one line of code... Commented Jan 26, 2016 at 22:55

You must log in to answer this question.

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