Quick cds with Aliases

If you do a lot of work in some particular directories, it can be handy to make aliases () that take you to each directory quickly. For example, this C shell alias lets you type pwr to change to the /tutorials/troff/pwrtools directory:

alias pwr cd /tutorials/troff/pwrtools

(If your shell doesn't have aliases, you can use a shell function (). A shell script () won't work, though, because it runs in a subshell ().)

When you pick the alias names, it's a good idea not to conflict with command names that are already on the system. Article shows how to pick a new name.

If you have a lot of these directory-changing aliases, you might want to put them in a separate file named something like cd_aliases. Then add these lines to your cshrc file:

source ~ 
alias setcds source ~/.cd_aliases setcds

That reads your aliases into each shell. If you edit the cd_aliases file, you can read the new file into your shell by typing setcds from any directory.

Finally, if you're in a group of people who all work on the same directories, you could make a central alias file that everyone reads from their cshrc files as they log in. Just use the setup above.

- JP