Howto: Less typing in the command line

If your like me, a command line junky and you are tired of typing so much here is a simple quick and effective tip.
The BASH shell has several environment variables that can be manipulated. The PATH variable is well known. Another useful variable is CDPATH. As PATH is a list of search paths for commands, so is CDPATH a list of directories used as search path for the "cd" command.
Example: At one ftp server we serve a lot of software, including several of the most popular Linux distributions. The local path to these distributions involves a lot of typing:

defcon@ion:~$ cd /usit/ion/ftp/linux/
defcon@ion:/usit/ion/ftp/linux$

From here, I can jump into "slackware/", "centos/", "debian/" and so on. But it's simpler when using CDPATH:

defcon@ion:~$ export CDPATH="/usit/ion/ftp/linux"
defcon@ion:~$ cd slackware
/usit/ion/ftp/linux/slackware
defcon@ion:/usit/ion/ftp/linux/slackware$

Nice huh?

An even lazier method (involving less typing) is to use alias:

defcon@ion:~$ alias s="cd /usit/ion/ftp/linux/slackware"
defcon@ion:~$ s
defcon@ion:/usit/ion/ftp/linux/slackware$

But then I have to create one alias for each directory. Oh the choices!

Clicky Web Analytics