I've been relying on this hack for jumping around in the file system for a couple of years before finding out today that I can do the same thing using native Bash by activating the option cdable_vars
.
The only thing I miss is tab completion. If I put this in my .bashrc
or .bash_profile
:
shopt -s cdable_vars
export mydir="$HOME/my/nested/directory"
Tab completion isn't expanding mydir
when I try to cd
into it from the prompt. Is there a way to activate this behavior in Bash?
1 Answer 1
To activate this completion you need the bash-completion package.
If the package is installed (often by default) just add these lines in your .bashrc
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
If not: https://repology.org/project/bash-completion/versions
-
Weird, I've always used completion everywhere without having this installed. Anyway now it does what I want, thanks a lot!mrzool– mrzool2015年11月24日 13:15:23 +00:00Commented Nov 24, 2015 at 13:15
-
The tab completion works with the
cd
command, though I use the path often with themv
command, which does not work. I wonder, if it could work as well.xralf– xralf2017年06月22日 22:04:31 +00:00Commented Jun 22, 2017 at 22:04 -
1@djangoliv Your link is brokenMax Coplan– Max Coplan2019年02月11日 18:39:18 +00:00Commented Feb 11, 2019 at 18:39