[comp.unix.questions] Setting PS1 prompt to show current directory.

dansh@caus-dp.UUCP (Dan Harris) (11/13/87)

I am currently using the Bourne shell on an Intel 310 xenix system
and I was wondering how to set the cursor prompt to indicate what
directory I am working in.
 

lenny@icus.UUCP (Lenny Tropiano) (11/15/87)

In article <275@caus-dp.UUCP> dansh@caus-dp.UUCP (Dan Harris) writes:
>I am currently using the Bourne shell on an Intel 310 xenix system
>and I was wondering how to set the cursor prompt to indicate what
>directory I am working in.
> 

My solution is to constantly reset PS1 environment variable after
each invocation of "cd": (place this in your .profile)

c()
{
	cd $*
	PS1="`pwd`] " ; export PS1
}

Now change directories with:

$ c /
/] c usr
/usr] c /bin
/bin]

Hope this helps.
Lenny
-- 
============================ US MAIL:   Lenny Tropiano, ICUS Computer Group
 IIIII   CCC   U   U   SSSS             PO Box 1
   I    C   C  U   U  S                 Islip Terrace, New York  11752
   I    C      U   U   SSS   PHONE:     (516) 968-8576 [H] (516) 582-5525 [W] 
   I    C   C  U   U      S  AT&T MAIL: ...attmail!icus!lenny  TELEX: 154232428
 IIIII   CCC    UUU   SSSS   UUCP:
============================       ...{uunet!godfre, mtune!quincy}!\
               ...{ihnp4, boulder, harvard!talcott, skeeve, ptsfa}! >icus!lenny 
"Usenet the final frontier"        ...{cmcl2!phri, hoptoad}!dasys1!/

ron@topaz.rutgers.edu (Ron Natalie) (11/17/87)

You can't.  Plain and simple.

It requires a 5R2 or later Bourne shell and its shell function
feature to accomplish it.  Ksh from the UNIX toolchest will
provdie the functionality.

-Ron

tim@ism780c.UUCP (11/18/87)

In article <275@caus-dp.UUCP> dansh@caus-dp.UUCP (Dan Harris) writes:
< I am currently using the Bourne shell on an Intel 310 xenix system
< and I was wondering how to set the cursor prompt to indicate what
< directory I am working in.
<  

PS1=.

What?  You wanted the absolute path name?  Oh.  Never mind...
-- 
Tim Smith, Knowledgian		{sdcrdcf,uunet}!ism780c!tim
				tim@ism780c.isc.com

mike@cimcor.UUCP (Michael Grenier) (11/18/87)

In article <16549@topaz.rutgers.edu>, ron@topaz.rutgers.edu (Ron Natalie) writes:
> You can't.  Plain and simple.
> 
> It requires a 5R2 or later Bourne shell and its shell function
> feature to accomplish it.  Ksh from the UNIX toolchest will
> provdie the functionality.
> 
> -Ron


I admit that I have 5.2 (Microport) but all I did was

    PS1=`pwd`

which worked fine for me.

    -Mike 
    meccts!cimcor!mike

marcos@caus-dp.UUCP (Marcos R. Della) (11/26/87)

In article <421@cimcor.UUCP>, mike@cimcor.UUCP (Michael Grenier) writes:
> In article <16549@topaz.rutgers.edu>, ron@topaz.rutgers.edu (Ron Natalie) writes:
> > You can't.  Plain and simple.
> > 
> > -Ron
> 
> I admit that I have 5.2 (Microport) but all I did was
> 
>     PS1=`pwd`
> 
>     -Mike 

The problem with what your doing with the PS1=`pwd` is
that you are not accounting for the changing of directories.
That is the main reason for trying to get the system to
recognise the fact that there has been a directory change
and the PS1 promt needs to be changed.

Under the 'C' shell, we have had no problems putting this
together, however the bourne shell under which almost everyone
runs, it doesn't work at all. We will be installing a Sperry
5000/80 here in a month or so and will have a little better
operating system, but so far, everyone thinks that its not
going to work...

Marcos
-- 
...!lll-crg -> !csustan -\                           | Whatever I said doesn't
            ...!sdsu ----->->!polyslo!caus-dp!marcos | mean diddly as I forgot
  ...!ihnp4 -> !csun ----/                           | it even before finishing
            ...!dmsd ---/                            | typing it all out!!!