PS1 change (ksh)

Tony L. Hansen hansen at pegasus.UUCP
Sun Mar 24 03:20:28 AEST 1985


<< how do you get the current directory in the prompt?
<<
< If you want the cwd in the prompt, just make a new function called, say, ch:
< 
< ch()
< {
< 	if cd $1;then PS1="[`pwd`] ";fi
< }

This of course requires you to use the name "ch" instead of "cd" to change
directories. More thorough would be to do the following:

	alias cd=__cd _cd=cd
	function __cd { _cd $*;PS1="[$PWD] "; }

Even better is to do just:

	PWD='[$PWD] '

and not modify cd at all. This will work in the most recent versions of ksh.

< This will work in SVR2 sh as well as ksh.

Neither of the above two solutions will work in the SVr2 sh. I don't know if
the version of ksh available outside of AT&T supports the second solution.

					Tony Hansen
					pegasus!hansen



More information about the Comp.unix.wizards mailing list