[comp.unix.questions] $cwd in prompt???

jc@raven.bu.edu (James Cameron) (06/18/91)

>>>>> On 18 Jun 91 03:41:07 GMT, bjsvec@cats.ucsc.edu (Brandon Jason Svec) said:



||> Can someone tell me how to get my prompt to show the current working 
||> directory?

||> I have tried something like this:

||> alias cd "cd;set prompt = $cwd"  # so it will update each time I cd
||> set prompt = $cwd

||> email please...
||> thanks,
||> brandon


Well, a basic solution to this would be this alias which could go in
either your .alias file if you have one, or .login:


alias cd 'cd \!*;set prompt = "$HOST [$cwd] % "'


which gives me when I am in my home directory:

raven [/u4/home/jc] % 


The above alias can be modified for X11 users to change the title 
and name of the current xterm.


jc

--
					-- James Cameron  (jc@raven.bu.edu)

Signal Processing and Interpretation Lab.  Boston, Mass  (617) 353-2879
------------------------------------------------------------------------------
"But to risk we must, for the greatest hazard in life is to risk nothing.  For
the man or woman who risks nothing, has nothing, does nothing, is nothing."
	(Quote from the eulogy for the late Christa McAuliffe.)

simonm@mel.dit.csiro.au (Simon McClenahan) (06/18/91)

In article <JC.91Jun18021304@raven.bu.edu>, jc@raven.bu.edu (James Cameron) writes:
|> >>>>> On 18 Jun 91 03:41:07 GMT, bjsvec@cats.ucsc.edu (Brandon Jason Svec) said:
|> ||> Can someone tell me how to get my prompt to show the current working 
|> ||> directory?
|> ||> I have tried something like this:
|> ||> alias cd "cd;set prompt = $cwd"  # so it will update each time I cd
|> ||> set prompt = $cwd
|> 
|> Well, a basic solution to this would be this alias which could go in
|> either your .alias file if you have one, or .login:
|> 
|> alias cd 'cd \!*;set prompt = "$HOST [$cwd] % "'
|> 
|> which gives me when I am in my home directory:
|> 
|> raven [/u4/home/jc] % 
|> 
I have this in my .cshrc ....

a       setprompt       'set prompt="[`hostname`:`pwd` -\\!] " '
setprompt
a       cd      'chdir \!* && setprompt ; ls -r -t'


of course, the ls -r -t is just a nice reverse-time listing, which is usually
the first think I want to do when I change directories

--
|Simon McClenahan CSIRO, | Cray Supercomputing Support Group             |
|55 Barry St, Carlton,   | (TEL) +61 3 347 8644   (FAX) +61 3 347 8987   |
|VIC 3053, Australia     | Internet:simonm@mel.dit.csiro.au              |
|                     Waste not what I want...                           |

skeeve@hpb.cis.pitt.edu (John Huffman) (06/18/91)

In article <17153@darkstar.ucsc.edu> bjsvec@cats.ucsc.edu (Brandon Jason Svec) writes:
>
>
>Can someone tell me how to get my prompt to show the current working directory?
>
>I have tried something like this:
>
>alias cd "cd;set prompt = $cwd"  # so it will update each time I cd
>set prompt = $cwd

I use the following in my .cshrc:

alias setprompt 'set prompt="`/usr/ucb/hostname`:`pwd`#\\!>"'
alias cd 'chdir \!* && setprompt'
alias pushd 'pushd \!* && setprompt'
alias popd 'popd \!* && setprompt'
setprompt

This takes care of at least most of the cases.

						- John Huffman

yzarn@lhdsy1.chevron.com (Philip Yzarn de Louraille) (06/19/91)

In article <17153@darkstar.ucsc.edu> bjsvec@cats.ucsc.edu (Brandon Jason Svec) writes:
>
>
>Can someone tell me how to get my prompt to show the current working directory?
>
>I have tried something like this:
>
>alias cd "cd;set prompt = $cwd"  # so it will update each time I cd
>set prompt = $cwd

alias cd      cd \!\* \; set prompt=`echo $cwd`
-- 
  Philip Yzarn de Louraille                 Internet: yzarn@chevron.com
  Research Support Division                 Unix & Open Systems
  Chevron Information & Technology Co.      Tel: (213) 694-9232
  P.O. Box 446, La Habra, CA 90633-0446     Fax: (213) 694-7709

jerovh@neabbs.UUCP (JEROEN V.HILST) (06/19/91)

For me (csh shell) this works, (prints a command-number and the dir):
alias cd 'cd \!*; set prompt = "! `pwd`> "'
set prompt = "! `pwd`> "
best of luck.

rob@iccdev.indcomp.com (Rob Rich) (06/20/91)

jerovh@neabbs.UUCP (JEROEN V.HILST) writes:

>For me (csh shell) this works, (prints a command-number and the dir):
>alias cd 'cd \!*; set prompt = "! `pwd`> "'
>set prompt = "! `pwd`> "
>best of luck.

_Watch Out_ using this on an HP9000/8xx machine. If you ever accidently 
hit the "ENTER" key instead of the "RETURN" key (an HP block mode feature),
you will create all kinds of bogus files in your current directory.

It seems the "ENTER" key (block mode send), causes the prompt line to use
the '>' symbol as an I/O redirection, writing to any file that you typed as
a command :-( . I found this out the _hard_ way.

--
   Rob
                                           |  Robert M. Rich, Jr.
   Internet: rob@iccdev.indcomp.com        |  Industrial Computer Corporation
   UUCP : ..!{emory,gatech}!iccdev!rob     |  5871 Glenridge Drive, Suite 300
   Voice: 404/255-8336 FAX: 404/250-0602   |  Atlanta, Georgia  30328