* Need to display $PWD in prompt using /bin/ksh
@ 1996-11-27 5:00 clos
1996-11-28 5:00 ` Raymond N Shwake
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: clos @ 1996-11-27 5:00 UTC (permalink / raw)
We are using Korn shell (/bin/ksh) and I would like to have the shell display my
present working directory ($PWD) in my command prompt evertime I "cd" to a
different directory. I have tried the following aliases in my .profile but with
out success:
alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
alias cd='cd \!* ; p'
Any ideas on what I am doing wrong?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
` (2 preceding siblings ...)
1996-11-28 5:00 ` Edgar Hiersekorn
@ 1996-11-28 5:00 ` Harald Finster
1996-11-28 5:00 ` Mathew E Goldstein
1996-12-02 5:00 ` Ian Mortimer
5 siblings, 0 replies; 11+ messages in thread
From: Harald Finster @ 1996-11-28 5:00 UTC (permalink / raw)
Cc: finster
Hi,
here is a selection of promt-generation methods
(without warranty!)
# For a prompt like 'alfred:/usr/users/ave> ' use this line:
#PS1=`hostname`":"'$PWD'"> "
#PS1= "> "
# This prompt displays history-index and
# the last two components of path:
#PS1="("!")""..."'${PWD#${PWD%/*/*}}'"> "
# This prompt displays the last two components of path:
# It is incorrect if the path has less than 2 components!!
# e.g.
# if current path is /usr/users/ave/finster/C++lib/xdrstream
# .../C++lib/xdrstream>
PS1="..."'${PWD#${PWD%/*/*}}'"> "
Good luck
Harald
--
Harald Finster ave GmbH Aachen
Seffenter Weg 29 Dennewartstr. 27
52074 Aachen 52068 Aachen
priv: +49 241 84075 +49 241 9631530
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
` (3 preceding siblings ...)
1996-11-28 5:00 ` Harald Finster
@ 1996-11-28 5:00 ` Mathew E Goldstein
1996-11-28 5:00 ` Roland Kruse
1996-12-02 5:00 ` Ian Mortimer
5 siblings, 1 reply; 11+ messages in thread
From: Mathew E Goldstein @ 1996-11-28 5:00 UTC (permalink / raw)
clos@ivory.trentu.ca wrote:
: I have tried the following aliases in my .profile but with out success:
:
: alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
: alias cd='cd \!* ; p'
I put
alias cd 'cd \!* ; set prompt=`pwd`">"'
in my .cshrc file and that works for me.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Visit my home page. http://mason.gmu.edu/~mgoldste/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-28 5:00 ` Mathew E Goldstein
@ 1996-11-28 5:00 ` Roland Kruse
0 siblings, 0 replies; 11+ messages in thread
From: Roland Kruse @ 1996-11-28 5:00 UTC (permalink / raw)
Cc: rk
Mathew E Goldstein wrote:
>
> clos@ivory.trentu.ca wrote:
>
> : I have tried the following aliases in my .profile but with out success:
> :
> : alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
> : alias cd='cd \!* ; p'
You don't need an alias at all, just do this:
PS1="\$PWD# "
The important thing is the \ before $PWD, it forces the shell
to re-evaluate $PWD each time the prompt is printed.
BTW, I don't like the "#" in your prompt, it looks too much like
a root prompt. Personally, I use
PS1="`hostname`:`whoami` \$PWD> "
BTW2, you should put all alias and prompt settings in a
.kshrc file, and just
ENV=$HOME/.kshrc; export ENV
in .profile.
Roland Kruse
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
@ 1996-11-28 5:00 ` Raymond N Shwake
1996-11-29 5:00 ` John Meyers, Computing Services
1996-11-28 5:00 ` Michael Livingston
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Raymond N Shwake @ 1996-11-28 5:00 UTC (permalink / raw)
clos@ivory.trentu.ca writes:
>We are using Korn shell (/bin/ksh) and I would like to have the shell display
>my present working directory ($PWD) in my command prompt evertime I "cd" to a
>different directory. I have tried the following aliases in my .profile but with
>out success:
>
> alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
> alias cd='cd \!* ; p'
Add something like the following to your .profile:
PS1='!: $PWD> '
This will generate both a command number and the current directory.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
1996-11-28 5:00 ` Raymond N Shwake
@ 1996-11-28 5:00 ` Michael Livingston
1996-11-28 5:00 ` Edgar Hiersekorn
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Michael Livingston @ 1996-11-28 5:00 UTC (permalink / raw)
On Wed, 27 Nov 1996 clos@ivory.trentu.ca wrote:
>
>
> We are using Korn shell (/bin/ksh) and I would like to have the shell display my
> present working directory ($PWD) in my command prompt evertime I "cd" to a
> different directory. I have tried the following aliases in my .profile but with
> out success:
>
> alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
> alias cd='cd \!* ; p'
>
>
> Any ideas on what I am doing wrong?
>
>
I hate having the command prompt taking up a significant part of the line
as it can when the current working directory is in it. When I'm in a
windowing environment I alias cd to a function that puts $PWD in the
terminal window's title bar. For xterm this is:
echo "\033]2;${PWD}\007\c"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
1996-11-28 5:00 ` Raymond N Shwake
1996-11-28 5:00 ` Michael Livingston
@ 1996-11-28 5:00 ` Edgar Hiersekorn
1996-11-28 5:00 ` Harald Finster
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Edgar Hiersekorn @ 1996-11-28 5:00 UTC (permalink / raw)
clos@ivory.trentu.ca wrote:
>We are using Korn shell (/bin/ksh) and I would like to have the shell display my
>present working directory ($PWD) in my command prompt evertime I "cd" to a
>different directory. I have tried the following aliases in my .profile but with
>out success:
>
> alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
> alias cd='cd \!* ; p'
>
>
>Any ideas on what I am doing wrong?
Don't use an alias, just define PS1 in .profile:
PS1="`hostname`:\$PWD#"
Watch the backslash befor $PWD!
--
/| Edgar Hiersekorn email: hiersekorn@addon.de
/ | Leiter Bereich UNIX Phone: +49 (7031) 717722
/ ( ) A d d O n Fax: +49 (7031) 717710
/___| Systemhaus GmbH Mobil: +49 (172) 7305922
http://www.addon.de/ <-------------------------
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-28 5:00 ` Raymond N Shwake
@ 1996-11-29 5:00 ` John Meyers, Computing Services
0 siblings, 0 replies; 11+ messages in thread
From: John Meyers, Computing Services @ 1996-11-29 5:00 UTC (permalink / raw)
In article <E1L35C.9Ms@atww.org>, rshwake@atww.org (Raymond N Shwake) writes:
> clos@ivory.trentu.ca writes:
>
>>We are using Korn shell (/bin/ksh) and I would like to have the shell display
>>my present working directory ($PWD) in my command prompt evertime I "cd" to a
>>different directory. I have tried the following aliases in my .profile but with
>>out success:
>>
>> alias p='PS1=`hostname|cut -d. -f1`":$PWD#"'
>> alias cd='cd \!* ; p'
You could always define a shell function in your .profile as,
cdp () {
cd $*
PS1="`hostname|cut -f1 -d.`:`basename $PWD`> "
}
alias cd=cdp
Just a reminder that you can display ksh funtions using the 'typeset -f'
command. :)
John Meyers
Computing Services
E-Mail: jmeyers@wright.edu
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
` (4 preceding siblings ...)
1996-11-28 5:00 ` Mathew E Goldstein
@ 1996-12-02 5:00 ` Ian Mortimer
1996-12-07 5:00 ` system PRIVILEGED account
5 siblings, 1 reply; 11+ messages in thread
From: Ian Mortimer @ 1996-12-02 5:00 UTC (permalink / raw)
clos@ivory.trentu.ca wrote:
> We are using Korn shell (/bin/ksh) and I would like to have the shell display my
> present working directory ($PWD) in my command prompt evertime I "cd" to a
> different directory.
I put this in my .profile:
PS1='${PWD#$HOME/}> '
This gives me a prompt showing the current directory in relation
to my home directory.
Ian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-12-02 5:00 ` Ian Mortimer
@ 1996-12-07 5:00 ` system PRIVILEGED account
1996-12-09 5:00 ` Ian Mortimer
0 siblings, 1 reply; 11+ messages in thread
From: system PRIVILEGED account @ 1996-12-07 5:00 UTC (permalink / raw)
mortimer@physics.uq.oz.au (Ian Mortimer) wrote:
>clos@ivory.trentu.ca wrote:
>
>
>> We are using Korn shell (/bin/ksh) and I would like to have the shell display my
>> present working directory ($PWD) in my command prompt evertime I "cd" to a
>> different directory.
>
>I put this in my .profile:
>
> PS1='${PWD#$HOME/}> '
>
>This gives me a prompt showing the current directory in relation
>to my home directory.
>
>Ian
It does not work !!!!!!!!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Need to display $PWD in prompt using /bin/ksh
1996-12-07 5:00 ` system PRIVILEGED account
@ 1996-12-09 5:00 ` Ian Mortimer
0 siblings, 0 replies; 11+ messages in thread
From: Ian Mortimer @ 1996-12-09 5:00 UTC (permalink / raw)
system PRIVILEGED account (root) wrote:
> mortimer@physics.uq.oz.au (Ian Mortimer) wrote:
> >clos@ivory.trentu.ca wrote:
> >
> >
> >> We are using Korn shell (/bin/ksh) and I would like to have the shell display my
> >> present working directory ($PWD) in my command prompt evertime I "cd" to a
> >> different directory.
> >
> >I put this in my .profile:
> >
> > PS1='${PWD#$HOME/}> '
> >
> >This gives me a prompt showing the current directory in relation
> >to my home directory.
> >
> >Ian
> It does not work !!!!!!!!
It works for me. Is HOME defined? Did you use single quotes?
If you use double quotes you need to escape at least the first $ with a \.
Are you using ksh? This won't work with other shells.
Ian
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~1996-12-09 5:00 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-11-27 5:00 Need to display $PWD in prompt using /bin/ksh clos
1996-11-28 5:00 ` Raymond N Shwake
1996-11-29 5:00 ` John Meyers, Computing Services
1996-11-28 5:00 ` Michael Livingston
1996-11-28 5:00 ` Edgar Hiersekorn
1996-11-28 5:00 ` Harald Finster
1996-11-28 5:00 ` Mathew E Goldstein
1996-11-28 5:00 ` Roland Kruse
1996-12-02 5:00 ` Ian Mortimer
1996-12-07 5:00 ` system PRIVILEGED account
1996-12-09 5:00 ` Ian Mortimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox