Unix Power ToolsUnix Power ToolsSearch this book

31.12. Marking Your Place with a Shell Variable

The following alias stores the current directory name in a variable:

alias mark 'set \!:1=$cwd'

so as to use a feature of the C shell:

% mark here
   ...
% cd here

One need not even type $here. If a directory does not exist, csh tries searching its cdpath (Section 31.5), then tries to evaluate the name as a variable.

(I generally use pushd and popd (Section 31.7) to store directory names; mark is more useful with commands that need to look in two different paths, and in that case $here is necessary anyway. Ah well.)

[In bash and zsh, you can do this by setting cdable_vars . In your shell setup file (Section 3.3), use cdable_vars=1 for bash or setopt cdable_vars or setopt -T for zsh. -- JP]

-- CT



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.