Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: Bourne Shell Question? Message-ID: <1996@solo12.cs.vu.nl> Date: 1 Feb 89 16:20:17 GMT References: <8517@dasys1.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 35 dap9702@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@cs.vu.nl, mcvax!botter!maart