Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!hao!gatech!bloom-beacon!bu-cs!bucsb!eap From: eap@bucsb.UUCP (Eric Pearce) Newsgroups: comp.unix.wizards Subject: Re: How to have PS1 evaluated after each "cd" Message-ID: <1374@bucsb.UUCP> Date: 31 Dec 87 18:30:52 GMT References: <574@ambush.UUCP> <1876@netsys.UUCP> Reply-To: eap@bucsb.UUCP (Eric Pearce) Organization: BD&HR (Beer Drinkers & Hell Raisers) Lines: 31 In article <1876@netsys.UUCP> lee@netsys.UUCP (Lee Chen,Staff) writes: > > Not So Long Ago there was a discussion about how to have the present >working directory evaluated and displayed as part of the PS1 prompt. >Would anyone (or two :-) care to summarize on effective solutions to >this "problem" via ksh, csh, sh, *sh script or C ? I've been using this for quite a while under csh/tcsh (I did not write it myself) # the following will set the prompt for the user to be the last element # of the current directory path. To remove this remove the ":t" from the # setprompt alias, the cd, pushd, popd aliases work to maintain the correct # directory printed on the screen alias setprompt 'set prompt="$cwd:t ";\\ if (x$cwd == x"/")set prompt="[/] ";' alias cd 'if ("\!:0-$" == cd) cd;\\ if ("\!:0-$" != cd) cd \!$;\\ setprompt' alias pushd 'if ("\!:0-$" == pushd) pushd;\\ if ("\!:0-$" != pushd) pushd \!$;\\ setprompt' alias popd 'if ("\!:0-$" == popd) popd;\\ if ("\!:0-$" != popd) popd \!$;\\ setprompt' setprompt; -- ------------------------------------------------------------------------------- UUCP !harvard!bu-cs!bucsb!eap ARPANET eap@bucsb.bu.edu CSNET eap%bucsb@bu-cs