Bash – Automatically add slash when navigating through symlink

autocompletebashcd-commandsymlink

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?

Best Answer

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'
Related Question