Dynamic Prompt in Korn Shell

Dynamic Prompt in Korn Shell

Post by John Doone » Tue, 10 Sep 1996 04:00:00



I'm trying to set my prompt so that it states the current directory I am
in. In the csh it is very easy, you set your prompt variable to `pwd`,
but when I try this in the Korn shell the prompt is set once and does
not change when you change directories.
In manuals I have found they note a variable PS1, which is the primary
prompt string. I have tried modifing PS1 with the same results.

Before I put more time into this, I am sure someone has solved
this problem already and I would appreciate the help.

Thanks
JD

 
 
 

Dynamic Prompt in Korn Shell

Post by Greg Mill » Tue, 10 Sep 1996 04:00:00




>: In manuals I have found they note a variable PS1, which is the primary
>: prompt string. I have tried modifing PS1 with the same results.
>Csh:
>    alias cd 'chdir \!:1; set prompt = "`pwd` "'
>Ksh:
>    PS1='${PWD} '
>-Yiorgos.


Is is possible to list the machine name as well as the time
using ksh?  
For example:
[3:43pm] harpo:/users/greg>

In tcsh you can use: set prompt = "[%t] %m:%/%# "
but I'm not sure how to do this in ksh.....

tnx!

Greg

 
 
 

Dynamic Prompt in Korn Shell

Post by Yiorgos Adamopoul » Tue, 10 Sep 1996 04:00:00


: In manuals I have found they note a variable PS1, which is the primary
: prompt string. I have tried modifing PS1 with the same results.

Csh:
        alias cd 'chdir \!:1; set prompt = "`pwd` "'

Ksh:
        PS1='${PWD} '

-Yiorgos.

 
 
 

Dynamic Prompt in Korn Shell

Post by Thomas M. Buccel » Tue, 10 Sep 1996 04:00:00



} I'm trying to set my prompt so that it states the current directory I am
} in. In the csh it is very easy, you set your prompt variable to `pwd`,
} but when I try this in the Korn shell the prompt is set once and does
} not change when you change directories.
} In manuals I have found they note a variable PS1, which is the primary
} prompt string. I have tried modifing PS1 with the same results.
} Before I put more time into this, I am sure someone has solved
} this problem already and I would appreciate the help.

use
        export PS1='${PWD}->' in .profile

Tom

--


#include <std_disclaimer.h>

 
 
 

Dynamic Prompt in Korn Shell

Post by Kevin Aquilin » Wed, 11 Sep 1996 04:00:00



> I'm trying to set my prompt so that it states the current directory I am
> but when I try this in the Korn shell......

In your .profile put in
PS1="\${PWD} "
export PS1
 
 
 

Dynamic Prompt in Korn Shell

Post by Will Mengari » Wed, 11 Sep 1996 04:00:00



>I'm trying to set my prompt so that it states the current directory
>I am in. [...] when I try this in the Korn shell the prompt
>is set once and does not change when you change directories.
>Before I put more time into this, I am sure someone has solved
>this problem already and I would appreciate the help.

I use
  export PS1='//'`hostname`'/'`tty|sed 's./dev/..'`'$PWD $'
in which the '$PWD' is the feature you want (but try the whole line,
the rest of the information can be useful at times).

--

"Today's Price [INLINE]"
      --Insight Direct at <http://www.insight.com>, using Lynx, Tu 10 Sep 96

 
 
 

Dynamic Prompt in Korn Shell

Post by Semir el.Fak » Wed, 11 Sep 1996 04:00:00


this is the easy way to do in .profile or at the prompt do:
PS1='$PWD $ '
and you will be done!

 
 
 

Dynamic Prompt in Korn Shell

Post by Dave Bro » Wed, 11 Sep 1996 04:00:00



:

: >: In manuals I have found they note a variable PS1, which is the primary
: >: prompt string. I have tried modifing PS1 with the same results.
:
: >Csh:
: >  alias cd 'chdir \!:1; set prompt = "`pwd` "'
:
: >Ksh:
: >  PS1='${PWD} '
:
: >-Yiorgos.

:
: Is is possible to list the machine name as well as the time
: using ksh?  
: For example:
: [3:43pm] harpo:/users/greg>
:
: In tcsh you can use: set prompt = "[%t] %m:%/%# "
: but I'm not sure how to do this in ksh.....

man hostname

--Dave
--
WARNING: sending me junk-email will be interpreted as granting permission to
bomb your offices and machine-gun your children. (10 in 4 days, 3 in 1 hour)
(thanks, Simon!)                    http://www.csclub.uwaterloo.ca/~dagbrown

 
 
 

Dynamic Prompt in Korn Shell

Post by Nathan SIVAPATHA » Wed, 11 Sep 1996 04:00:00


try             PS1='${PWD}'

This is off the top of my head. May need a minor quote adjustments. I use the
second one as I manage many UNIX boxes and I need to know which box Im on and
what Id Im logged in as. if am root it helps me to play easy.

--
Nathan SIVAPATHAM

 
 
 

Dynamic Prompt in Korn Shell

Post by Kevin MacNe » Fri, 13 Sep 1996 04:00:00


]try             PS1='${PWD}'

]This is off the top of my head. May need a minor quote adjustments. I use
]the second one as I manage many UNIX boxes and I need to know which box Im
]on and what Id Im logged in as. if am root it helps me to play easy.

Or if you like tilde notation:


This method was posted here a few months ago, but unfortunately I lost the
attribution.  But whoever came up with it, take a bow.

 
 
 

Dynamic Prompt in Korn Shell

Post by Brian Duan » Fri, 13 Sep 1996 04:00:00





> >: In manuals I have found they note a variable PS1, which is the primary
> >: prompt string. I have tried modifing PS1 with the same results.

> >Csh:
> >       alias cd 'chdir \!:1; set prompt = "`pwd` "'

> >Ksh:
> >       PS1='${PWD} '

> >-Yiorgos.

> Is is possible to list the machine name as well as the time
> using ksh?
> For example:
> [3:43pm] harpo:/users/greg>

> In tcsh you can use: set prompt = "[%t] %m:%/%# "
> but I'm not sure how to do this in ksh.....

PS1="$(uname -n):\$PWD "
note - the embedded command $(uname -n) is evaluated once only,
whereas the \$PWD is evaluated prior to delivering the prompt.

--
Brian Duane - NCR Corporation
(Formerly AT&T GIS, formerly NCR)

 
 
 

Dynamic Prompt in Korn Shell

Post by stickl.. » Tue, 17 Sep 1996 04:00:00




> ]try             PS1='${PWD}'

This is how to have the time in the prompt

typeset -RZ2 _x1 _x2 _x3
let SECONDS=$(/bin/date '+3600*%H+60*%M+%S')
_s='(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)'
TIME='"${_d[_s]}$_x1:$_x2:$_x3"'
PS1="${TIME}-> "