Quickly jump to a specific directory in the Linux shell.
Before installing this tool, please refer to this page to install CmdAutoComp
, which is used to auto-complete commands.
- Run
chmod +x jumpdir.sh
to givejumpdir.sh
execute permisson. - Append the contents of the
bashrc
to the.bashrc
in your home directory. And replacepath/to/jumpdir.sh
with the path where you putjumpdir.sh
. - Run
source ~/.bashrc
. - Try the following commands.
- Run
./jumpdir.sh -h
to get the help info. - Run
./jumpdir.sh -a
<alias>=<path>
to add an alias for the specified directory. - Run
./jumpdir.sh -d
<alias>
to delete an alias. - Run
./jumpdir.sh -l
to list all aliases. - Run
./jumpdir.sh -t
<alias>
to get the path related to an alias.
- Run
- Run
jcd
to list all aliases. - Run
jcd
<alias>
to jump to the specified directory.
source@debian:~/opensource/mine/linux-jcd$ ls
bashrc jumpdir.sh LICENSE README.md
source@debian:~/opensource/mine/linux-jcd$ chmod +x jumpdir.sh
source@debian:~/opensource/mine/linux-jcd$ pwd
/home/source/opensource/mine/linux-jcd
source@debian:~/opensource/mine/linux-jcd$ vim ~/.bashrc
source@debian:~/opensource/mine/linux-jcd$ tail -3 ~/.bashrc
function jcd {
cd $(/home/source/opensource/mine/linux-jcd/jumpdir.sh -t $1)
}
source@debian:~/opensource/mine/linux-jcd$ source ~/.bashrc
source@debian:~/opensource/mine/linux-jcd$ ./jumpdir.sh -a test=~
The alias test already exists, do you want to replace it? (y/n)
y
source@debian:~/opensource/mine/linux-jcd$ ./jumpdir.sh -l
test=/home/source
source@debian:~/opensource/mine/linux-jcd$ jcd test
source@debian:~$