Changing prompt to reflect new current working directory in ksh

Changing prompt to reflect new current working directory in ksh

Post by Uchak » Wed, 05 Dec 2001 16:30:30



Is it possible to change the prompt to  new present directory when the
cd command is used in a korn shell environment.

For example,

cd /tmp

/tmp>

cd /opt
/opt>

cd /usr/bin
/usr/bin>

etc.

In other words I want something like export PS1=`pwd`  with every
execution of cd.

Anyone with any information, please help.

Regards
Willy

 
 
 

Changing prompt to reflect new current working directory in ksh

Post by caiu » Thu, 06 Dec 2001 00:59:09


Quote:> Is it possible to change the prompt to  new present directory when the
> cd command is used in a korn shell environment.

> For example,

> cd /tmp

> /tmp>

> cd /opt
> /opt>

> cd /usr/bin
> /usr/bin>

> etc.

> In other words I want something like export PS1=`pwd`  with every

try:

export $PS1

 
 
 

Changing prompt to reflect new current working directory in ksh

Post by Brian Mille » Thu, 06 Dec 2001 01:15:45



Quote:> Is it possible to change the prompt to  new present directory when the
> cd command is used in a korn shell environment.

> For example,

> cd /tmp

> /tmp>

> cd /opt
> /opt>

> cd /usr/bin
> /usr/bin>

> etc.

> In other words I want something like export PS1=`pwd`  with every
> execution of cd.

> Anyone with any information, please help.

> Regards
> Willy

Korn shell is easy. For Korn shell put the following in your .profile or
your .kshrc, if you're using one:

PS1='($PWD)$'

Remember to export PS1. $PWD is a shell variable that is equal to the
present working directory.

C shell uses the same variable, but the files and syntax are different.

I think that Bourne shell requires that you alias the cd command.

Check Google in comp.unix.shell.  There are several postings that answer
your question.

Brian Miller
Reply address is munged.  Remove the CLIPTHIS.

 
 
 

Changing prompt to reflect new current working directory in ksh

Post by Markus Gyg » Thu, 06 Dec 2001 04:14:07



> Is it possible to change the prompt to  new present directory when the
> cd command is used in a korn shell environment.

Check http://dotfiles.com for an example (Shells -> ksh).

Markus

 
 
 

Changing prompt to reflect new current working directory in ksh

Post by David Ann » Thu, 06 Dec 2001 05:37:38



> > Is it possible to change the prompt to  new present directory when the
> > cd command is used in a korn shell environment.

> > For example,

> > cd /tmp

> > /tmp>

> > cd /opt
> > /opt>

> > cd /usr/bin
> > /usr/bin>

> > etc.

> > In other words I want something like export PS1=`pwd`  with every

> try:

> export $PS1

I prefer:

PS1="\$LOGNAME;\$PWD
`uname -n`> "
export PS1

The advantage here is that the very long path names don't shrink the
command line input area.