How to minimize typing when frequently changing directories?
The dirs -v
command will list the directory stack with numbers in front of each directory, and you can give a number argument to the pushd
command to have it jump to that directory. For example, if dirs -v
shows that the directory you wish to change to has 2
in front of it (i.e., is the third directory in the list), executing pushd +2
will change to that directory.
To save typing, you can shorten those commands by giving them aliases like this:
alias dv="dirs -v"
alias pd=pushd
You could use wildcards:
cd ../*test1 or even cd *t1
cd ../2010*test2
cd ../*bar
They are much more flexibles and you don't need to plan a script for each different situation, once you are used to them, you will use them for all kind of directories. Examples:
cd /e*/n*k will take you to /etc/network
cd /h* to /home
They are usable anywhere (ls
also of course so you can filter what to see)
bash wildcards