Bourne Shell Question?
Maarten Litmaath
maart at cs.vu.nl
Thu Feb 2 02:20:17 AEST 1989
dap9702 at dasys1.UUCP (Dan Powers) writes:
\ Does anyone know how to get a prompt in Bourne Shell that contains the
\current working directory (pwd).
One of the most frequently asked questions; it IS possible, but there is a
price you have to pay.
Solution I.
------------------------------cut here------------------------------
#! /bin/sh
#
# c: a script to change the prompt of the parent to the new working
# directory
# to put in $HOME/.profile:
#
# PARENT=$$
# export PARENT
# trap 'DIR=`cat $HOME/.dir`; cd $DIR; PS1="$DIR> "' 5
cd $1
pwd > $HOME/.dir
exec kill -5 $PARENT
------------------------------cut here------------------------------
Solution II.
If your sh knows shell functions:
------------------------------cut here------------------------------
c() # you cannot name this function `cd'
{
cd $1
PS1="`pwd`> "
}
--
"Does she play, er, tennis? |Maarten Litmaath @ VU Amsterdam:
Wink wink, notch notch!" |maart at cs.vu.nl, mcvax!botter!maart
More information about the Comp.unix.questions
mailing list