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.shto givejumpdir.shexecute permisson. - Append the contents of the
bashrcto the.bashrcin your home directory. And replacepath/to/jumpdir.shwith the path where you putjumpdir.sh. - Run
source ~/.bashrc. - Try the following commands.
- Run
./jumpdir.sh -hto 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 -lto list all aliases. - Run
./jumpdir.sh -t<alias>to get the path related to an alias.
- Run
- Run
jcdto 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:~$