Path: utzoo!attcan!uunet!samsung!gem.mps.ohio-state.edu!think!ames!amdahl!pacbell!sactoh0!jak From: jak@sactoh0.UUCP (Jay A. Konigsberg) Newsgroups: comp.unix.questions Subject: Re: Prompt as Current Directory? Summary: Bourne shell answer (yes it can be done) Keywords: Use a function in your .profile Message-ID: <2114@sactoh0.UUCP> Date: 18 Nov 89 02:11:57 GMT References: Reply-To: jak@sactoh0.UUCP (Jay A. Konigsberg) Organization: SAC-UNIX, Sacramento, Ca. Lines: 32 In article broadman@paul.rutgers.edu (Alan Broadman) writes: > >I have a (hopefully) simple question. How can you get the UNIX prompt >to always reflect the path to the current directory. You can't change the ' cd ' command itself because it is a Bourne shell built-in! However, the task can still be done. All that is required is that the PS1 and PS2 variables are set in the current shell layer. The script shown is placed in my .profile and works fine. One word of warning though, commands that give you a new shell, like newgrp, will wipe it out till your next login. Also, get in the habit of using "cdd" instead of "cd". #### SHOULD BE THE LAST LINES IN THE .profile #### # cdd - cd with a current directory in the prompt echo "Enter: \" cdd = \" to return to a $ prompt" cdd() { if [ "$1" = "=" ]; then PS1="$ "; PS2="> " else cd $1 PS1="`pwd` $ "; PS2="`pwd` > " fi } cdd -- ------------------------------------------------------------- Jay @ SAC-UNIX, Sacramento, Ca. UUCP=...pacbell!sactoh0!jak