[comp.unix.wizards] pwd prompts in unix

chh2@hera.uucp (27411-Cliff Halevi(M532)) (06/21/91)

Does anyone know how to get the prompt to show the current working
directory (like DOS does)?

Cliff Halevi
bellcore!hera!chh2
201-829-4989

ketell@tolkien (Gregory Ketell) (06/22/91)

How you set up your prompt depends on what shell you are running.  Here are
some methods I use.

CSH:
	Create two aliases in your .cshrc file
		alias cd	'cd \!*;promp'
		alias promp	'set prompt = "`hostname`:`pwd` ! > "'
	This will result in a prompt such as   tolkien:/usr/bin 23 > 
	which tells you which machine you are currently on, your path, and
	what history command you are on.

KSH:
	The Korn Shell has support for that built in.  All you do is set
	your prompt command in your .profile to something like
		PS1  $HOST:$PWD ! >
		export PS1
	and it will give you the same results as above.  
	(Please excuse me if this is not perfect.  I have not been on
	 the Korn Shell for quite some time.)

Good Luck,
Gregory G. Ketell
Director of Systems Engineering
Rimma Technologies, Inc. 
gketell@seq.csuhayward.edu

s902113@minyos.xx.rmit.oz.au (Luke Mewburn) (06/24/91)

ketell@tolkien (Gregory Ketell) writes:

>How you set up your prompt depends on what shell you are running.  Here are
>some methods I use.

>CSH:
>	Create two aliases in your .cshrc file
>		alias cd	'cd \!*;promp'
>		alias promp	'set prompt = "`hostname`:`pwd` ! > "'
>	This will result in a prompt such as   tolkien:/usr/bin 23 > 
>	which tells you which machine you are currently on, your path, and
>	what history command you are on.

Doing the following will give you the path as an index to your home (if
it can), so instead of:
   minyos [/u1/s90/s902113/bin] 58:
we get
   minyos [~s902113/bin] 58:
Also, support for pushd & popd is provided...
(NB: I didn't write the set_prompt [well, the 'sed' bit anyway], I just
 reconfigured it for my preferences of hostname & history index placing)

  alias set_prompt 'set prompt="$host"" [`dirs|sed -e '\''s| .*||'\''`] \\!: "'
  alias cd 'cd \!*; set_prompt'
  alias push 'pushd \!*; set_prompt'
  alias pop 'popd; set_prompt'

>KSH:
>	The Korn Shell has support for that built in.  All you do is set
>	your prompt command in your .profile to something like
>		PS1  $HOST:$PWD ! >
>		export PS1
>	and it will give you the same results as above.  
>	(Please excuse me if this is not perfect.  I have not been on
>	 the Korn Shell for quite some time.)

>Good Luck,
>Gregory G. Ketell
>Director of Systems Engineering
>Rimma Technologies, Inc. 
>gketell@seq.csuhayward.edu

jkmedcal@uokmax.ecn.uoknor.edu (Jeff Medcalf) (06/24/91)

ketell@tolkien (Gregory Ketell) writes:

>CSH:
>	Create two aliases in your .cshrc file
>		alias cd	'cd \!*;promp'
>		alias promp	'set prompt = "`hostname`:`pwd` ! > "'
>	This will result in a prompt such as   tolkien:/usr/bin 23 > 
>	which tells you which machine you are currently on, your path, and
>	what history command you are on.

This could be done in a single alias:

	alias cd 'cd \!* ; set prompt = "`hostname`:`pwd` ! > "'

and then follow this with a cd . command (which would stay in the cwd but
set the prompt.

In tcsh, I use the following to shell commands in my .cshrc:

set prompt=%m\[%c\]\{%!\}\:
set prompt2=%m\[%c\]\{%!\}\?

%m is replaced by the machine name, %c is replaced by the last element of the
cwd, and %! is replaced by the history number.

-- 
Jeff Medcalf   jkmedcal@uokmax.{uucp|ecn.uoknor.edu}    !chinet!uokmax!jkmedcal
BoB smokes *my* pipe!            We carry in our hearts the true country...
In 1869, the waffle iron was invented, thus solving the annoying tendency of
waffles to wrinkle in the dryer.                        No new tale to tell.

lijewski@theory.TC.Cornell.EDU (Mike Lijewski) (06/24/91)

In article <1991Jun24.140512.6143@uokmax.ecn.uoknor.edu> jkmedcal@uokmax.ecn.uoknor.edu (Jeff Medcalf) writes:
>
>ketell@tolkien (Gregory Ketell) writes:
>
>>CSH:
>>	Create two aliases in your .cshrc file
>>		alias cd	'cd \!*;promp'
>>		alias promp	'set prompt = "`hostname`:`pwd` ! > "'
>
>This could be done in a single alias:
>
>	alias cd 'cd \!* ; set prompt = "`hostname`:`pwd` ! > "'
>
>and then follow this with a cd . command (which would stay in the cwd but
>set the prompt.

And if you want pushd and popd to work correctly, you'll probably need the
following line:

alias pushd 'pushd \!*; cd .'; alias popd 'popd; cd .';

>Jeff Medcalf   jkmedcal@uokmax.{uucp|ecn.uoknor.edu}    !chinet!uokmax!jkmedcal

-- 
Mike Lijewski  (H)607/272-0238 (W)607/254-8686
Cornell National Supercomputer Facility
ARPA: mjlx@eagle.tc.cornell.edu  BITNET: mjlx@cornellf.bitnet
SMAIL:  25 Renwick Heights Road, Ithaca, NY  14850

reich@magnus.acs.ohio-state.edu (A Minor Diety) (06/25/91)

In article <1991Jun24.140512.6143@uokmax.ecn.uoknor.edu> jkmedcal@uokmax.ecn.uoknor.edu (Jeff Medcalf) writes:
|In tcsh, I use the following to shell commands in my .cshrc:
|
|set prompt=%m\[%c\]\{%!\}\:
|set prompt2=%m\[%c\]\{%!\}\?
|
|%m is replaced by the machine name, %c is replaced by the last element of the
|cwd, and %! is replaced by the history number.

I prefer tcsh and this method.  I use gnuemacs all the time and have
my PC keyboard remapped to work with emacs.  Tcsh uses the arrow keys
to select commands out of my history, the cut buffers also work (C-K
and C-Y).  Tcsh also has some advancements to the aliasing portion of
the code.  A reference to it on saqqara.cis.ohio-state.edu anonymous
ftp points to a location at cornell university ftp site (sorry that I
don't have the exact address on me)

Later
-- 
  DDDDDD             k                | reich@magnus.acs.ohio-state.edu
  D     D  `   cccc  k  kk   (^8      | Dick C. Reichenbach
  D     D  i  c      kkk              | "Humans have a way of showing up when
  DDDDDD   i   cccc  k  kk  WAS HERE  | you least expect them." - Denise Crosby

mday@icon.com (Matt Day) (06/26/91)

In article <1991Jun25.033343.21971@magnus.acs.ohio-state.edu> reich@magnus.acs.ohio-state.edu (A Minor Diety) writes:
>the code.  A reference to [tcsh] on saqqara.cis.ohio-state.edu anonymous
>ftp points to a location at cornell university ftp site (sorry that I
>don't have the exact address on me)

You can get the latest tcsh diffs from tesla.ee.cornell.edu:/pub/tcsh-5.20.
-- 
- Matt Day, Sanyo Icon R&D, mday@icon.com

konczal@sunmgr.ncsl.nist.gov (Joe Konczal) (06/26/91)

This is the kind of question that should be answered with something
like "Read answer number 4 in the Frequently Asked Questions list."

greywolf@unisoft.UUCP (The Grey Wolf) (06/28/91)

/* <1991Jun25.033343.21971@magnus.acs.ohio-state.edu> by reich@magnus.acs.ohio-state.edu (A Minor Diety)
 * In article <1991Jun24.140512.6143@uokmax.ecn.uoknor.edu> jkmedcal@uokmax.ecn.uoknor.edu (Jeff Medcalf) writes:
 * |In tcsh, I use the following to shell commands in my .cshrc:
 * |
 * |set prompt=%m\[%c\]\{%!\}\:
 * |set prompt2=%m\[%c\]\{%!\}\?
 * |
 * |%m is replaced by the machine name, %c is replaced by the last element of the
 * |cwd, and %! is replaced by the history number.

Why don't you do something like

set prompt=".> "

Seriously speaking, what is this drek doing in c.u.w?


-- 
# "Religion is a weapon invented by the sheep to keep the wolves in line."
# greywolf@unisoft.com