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?
Add a comment
|
1 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'
-
Wow, thank you! Is the
~/.inputrca part of bash or where does it belong to? Can I add it to my~/.bash_profileinstead?LastSecondsToLive– LastSecondsToLive2016-01-26 22:40:08 +00:00Commented Jan 26, 2016 at 22:40 -
Ok, it doesn't work in
~/.bash_profile. No problem just another file for.dotfiles...LastSecondsToLive– LastSecondsToLive2016-01-26 22:50:04 +00:00Commented Jan 26, 2016 at 22:50 -
You can actually do
bind 'set mark-symlinked-directories on'in anybashconfig file (or in the bash shell) if you prefer.Mikel– Mikel2016-01-26 22:51:37 +00:00Commented 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...LastSecondsToLive– LastSecondsToLive2016-01-26 22:55:20 +00:00Commented Jan 26, 2016 at 22:55