From: basiji@milton.u.washington.edu (David Basiji)
Newsgroups: comp.sys.next.misc
Subject: Summary: Current directory in prompt...
Date: 8 Apr 92 14:41:23 GMT
Article-I.D.: u.1992Apr8.144123.25838
Reply-To: basiji@u.washington.edu
Organization: University of Washington, Seattle


Well here's a sample of the responses I got to my request for a alias/script
to put the current working directory in the prompt.  There were too many
to include them all, but thatnks again to everyone who responded.

^L
From pbiron@weber.UCSD.EDU Mon Apr  6 19:57:30 1992
Received: from ucsd.edu by milton.u.washington.edu
	(5.65/UW-NDC Revision: 2.22 ) id AA10625; Mon, 6 Apr 92 19:57:27 -0700
Received: from weber.ucsd.edu by ucsd.edu; id AA08743
	sendmail 5.64/UCSD-2.2-sun via SMTP
	Mon, 6 Apr 92 19:57:26 -0700 for basiji@milton.u.washington.edu
Received: by weber (16.6/UCSDGENERIC.4)
	id AA04241 to basiji@milton.u.washington.edu; Mon, 6 Apr 92 19:57:24 -0700
Date: Mon, 6 Apr 92 19:57:24 -0700
From: pbiron@weber.UCSD.EDU (Paul Biron)
Message-Id: <9204070257.AA04241@weber>
To: basiji@milton.u.washington.edu
Subject: Re: How do I make shell prompt show working directory?
Newsgroups: comp.sys.next.misc
Organization: University of California, Los Angeles
Cc: 
Status: R

In article <basiji.702614445@milton> you write:
>
>The subject pretty much says it all.  I really miss this from my life
>in the DOS world.  How do I modify my .cshrc or .login to make this 
>happen?  
>
>Thanks,
>Dave
>basiji9@u.washington.edu


You'll probably get 1000's of these but here's what I use for /bin/csh:

alias cd 'cd \!*; set prompt="${cwd}:`whoami` % "'
alias pushd 'pushd \!*; set prompt="${cwd}:`whoami` % "'
alias popd 'popd \!*; set prompt="${cwd}:`whoami` % "'

You could probably leave off the `whoami` part on the end, but since I'm
frequently su'ing to other users I kind of like to know you I am at
all times.  Also note that I add the following as the *LAST* line of .login

cd .

so that the prompt is set right when I start.

${cwd} is the /bin/csh variable which contains the current working directory.

-- 
Paul Biron      pbiron@cns.caltech.edu
University of California, Los Angeles
Graduate School of Library and Information Science
Los Angeles, Ca. 90024

From @andrew.cmu.edu:anwar@mohammed.slip.andrew.cmu.edu Mon Apr  6 20:37:20 1992
Received: from PO3.ANDREW.CMU.EDU by milton.u.washington.edu
	(5.65/UW-NDC Revision: 2.22 ) id AA17762; Mon, 6 Apr 92 20:37:16 -0700
Received: from mohammed.slip.andrew.cmu.edu by po3.andrew.cmu.edu (5.54/3.15) id <AA27181> for basiji@milton.u.washington.edu; Mon, 6 Apr 92 23:37:06 EDT
Received: by mohammed.slip.andrew.cmu.edu (NeXT-1.0 (From Sendmail 5.52)/NeXT-2.0)
	id AA00749; Mon, 6 Apr 92 23:33:54 EDT
Date: Mon, 6 Apr 92 23:33:54 EDT
From: anwar@mohammed.slip.andrew.cmu.edu (Anwar M. Ghuloum)
Message-Id: <9204070333.AA00749@mohammed.slip.andrew.cmu.edu>
Received: by NeXT Mailer (1.63)
To: basiji@milton.u.washington.edu (David Basiji)
Subject: Re: How do I make shell prompt show working directory?
Status: R

In comp.sys.next.misc article <basiji.702614445@milton> you wrote:
> 

> The subject pretty much says it all.  I really miss this from my life
> in the DOS world.  How do I modify my .cshrc or .login to make this 

> happen?  

> 

> Thanks,
> Dave
> basiji9@u.washington.edu

Put these lines in your .cshrc:

alias set_prompt 'set prompt = \[`hostname`]$cwd"> "'
alias cd '\!:0-$; set_prompt'
set_prompt

I also find the following useful:

alias popd '\!:0-$; set_prompt'
alias pushd '\!:0-$; set_prompt'



--
Anwar Mohammed                           Graduate Student
anwar+@cs.cmu.edu  (NeXTmail welcome!)   School of Computer Science
Voice: +1 412 268 3043                   Carnegie-Mellon University
Fax:   +1 412 681 5739                   Pittsburgh, PA  15213-3890

From rkan@uhunix.uhcc.Hawaii.Edu Mon Apr  6 23:09:13 1992
Received: from uhunix.uhcc.Hawaii.Edu by milton.u.washington.edu
	(5.65/UW-NDC Revision: 2.22 ) id AA17947; Mon, 6 Apr 92 23:09:10 -0700
Received: by uhunix.uhcc.Hawaii.Edu (4.1/Sun690)
	id AA27618; Mon, 6 Apr 92 20:09:07 HST
Date: Mon, 6 Apr 92 20:09:07 HST
From: Ray Kan  <rkan@uhunix.uhcc.Hawaii.Edu>
Message-Id: <9204070609.AA27618@uhunix.uhcc.Hawaii.Edu>
To: basiji@milton.u.washington.edu
Subject: Re: How do I make shell prompt show working directory?
Newsgroups: comp.sys.next.misc
Organization: University of Hawaii
Cc: 
Status: R

In article <basiji.702614445@milton> you write:
>
>The subject pretty much says it all.  I really miss this from my life
>in the DOS world.  How do I modify my .cshrc or .login to make this 
>happen?  
>
>Thanks,
>Dave
>basiji9@u.washington.edu

Put this in your .cshrc:

alias cd 'cd \!*; set prompt="$cwd>"' (with all the quotes)

and put this in your .login if it isn't there already:

cd

set prompt="$cwd>" is what actually sets your prompt, $cwd
is your current working directory.  You can change what's within
the double quotes to make your prompt look the way you want, just include
$cwd in there for the working directory.  

You may want to put the host name in your prompt in case you log into 
several different systems and want to keep track of which system you are 
on, in this case add `hostname` within the double quotes: 

alias cd 'cd \!*; set prompt="`hostname`:$cwd>"' (with all the quotes)

(note that you need to use the back quotes in hostname).

You need to put 'alias cd...etc.'  because it has to reset your prompt
every time you 'cd' to a new directory in order to get that directory
into your prompt.  You also need the 'cd' in your .login because it
has to run 'cd' when you first log in or create a new terminal
shell to get the prompt there the first time.

Well hope this made sense, let me know if it doesn't.

Ray

From comp.sys.next.misc Tue Apr  7 07:43:30 1992