prompt changing on the fly

markp at valid.UUCP markp at valid.UUCP
Fri Feb 13 04:51:50 AEST 1987


> 	alias cd 'cd \!*; set prompt=$cwd> '
> 
> 	alias pushd 'pushd \!*; set prompt=$cwd> '
> 	alias popd 'popd; set prompt=$cwd> '

I have found it useful to be able to attach symbolic names to certain
directories during a session, so I have taken this scheme one step farther.
Any shell variable starting with zz is a "mark."  The shell variable zz
corresponds to the last directory you were in.  Here is the initialization
sequence from my .cshrc: (these don't affect the prompt, but that can be added)

	alias cd 'set zz=$cwd;chdir \!*'
	alias b 'set zzZZ=$cwd;chdir $zz\!*;set zz=$zzZZ;unset zzZZ'
	alias m 'set zz\!*=$cwd'
	set zz=$cwd

"cd" saves the current directory in zz and changes directory.
"b" by itself saves the current directory in zz and goes back to the previous
 directory (i.e. the previous value of zz).  Repeated invocations of "b"
 switch back and forth between the 2 most recent directories.
"b argument" saves the current directory in zz and changes to the directory
 zzargument.
"m argument" assigns the current working directory to the "argument" mark,
 i.e. zzargument.

The zz variable is initialized by .cshrc for proper operation of the aliases.
You can also initialize a number of zzvariables in your .cshrc if you want,
effectively giving symbolic names to directories which you frequent.  A
number of people I know do this using one alias per directory, but the m/b
method seems cleaner, and is more convenient to use in practice.

	Mark Papamarcos
	Valid Logic
	{ihnp4,hplabs}!pesnta!valid!markp



More information about the Comp.unix.wizards mailing list