Thread View: comp.sys.next.misc
1 messages
1 total messages
Started by David Basiji
Wed, 08 Apr 1992 14:41
Summary: Current directory in prompt...
Author: David Basiji
Date: Wed, 08 Apr 1992 14:41
Date: Wed, 08 Apr 1992 14:41
425 lines
15152 bytes
15152 bytes
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
In-Reply-To: <basiji.702614445@milton>
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
In-Reply-To: <basiji.702614445@milton>
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
Path: news.u.washington.edu!usenet.coe.montana.edu!rpi!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!umn.edu!csus.edu!netcomsv!nextdoor!john
From: john@nextdoor.com (John McCracken)
Newsgroups: comp.sys.next.misc
Subject: Re: How do I make shell prompt show working directory?
Message-ID: <1992Apr7.072725.6379@nextdoor.com>
Date: 7 Apr 92 07:27:25 GMT
Article-I.D.: nextdoor.1992Apr7.072725.6379
References: <basiji.702614445@milton>
Sender: john@nextdoor.com
Reply-To: john@nextdoor.com
Organization: Nextdoor Software, San Jose, CA, USA
Lines: 28
In article <basiji.702614445@milton> basiji@milton.u.washington.edu (David
Basiji) writes:
>
> 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?
>
I use /bin/csh as the default shell, and here's what I have in my .login file:
set myhost=`hostname`
alias SetPrompt 'set prompt="${myhost} [$cwd]-\\!% "'
alias cd 'cd \!* && SetPrompt'
alias cdl 'cd \!*; ls'
cd
This yields a prompt like:
nextdoor [/john/Library]-3%
where "nextdoor" is the host, "/john/Library" is the current working directory,
and "3" is the command number. The "cd" command has been modified to update
the prompt whenever I change directories, and "cdl" changes directories and
gives a listing of the new directory's contents.
--
John McCracken
john@nextdoor.com
From nether@wpi.WPI.EDU Tue Apr 7 08:37:36 1992
Received: from wpi.WPI.EDU by milton.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA04042; Tue, 7 Apr 92 08:37:32 -0700
Received: by wpi.WPI.EDU (5.65/4.7)
id AA00314; Tue, 7 Apr 92 11:37:26 EST
Date: Tue, 7 Apr 92 11:37:26 EST
From: nether@wpi.WPI.EDU (Joel C Belog)
Message-Id: <9204071537.AA00314@wpi.WPI.EDU>
To: basiji@milton.u.washington.edu
Subject: Re: How do I make shell prompt show working directory?
Newsgroups: comp.sys.next.misc
In-Reply-To: <basiji.702614445@milton>
Organization: Worcester Polytechnic Institute
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
In your .login file, add the lines:
set prompt="{$USER@$HOST %//} Query:: "
P.S. Quesry:: and the {}`s are just my little thing. If all you want is a
directory, then:
set prompt="$USER@HOST %//> "
will work. Explore a bit till you feel your prompt is comfortable and
does not strain the eyes :)
Luck,
Joel Belog
nether@wpi.wpi.edu
From samurai@uriel.cs.mcgill.ca Tue Apr 7 08:56:24 1992
Received: from opus-tc.CS.McGill.CA by milton.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA09819; Tue, 7 Apr 92 08:56:20 -0700
Received: from uriel.CS.McGill.CA by opus.cs.mcgill.ca with SMTP (5.65a/IDA-1.4.2c/SOCS-Guru-2c)
id AA15821 (mail destined for basiji@milton.u.washington.edu) on Tue, 7 Apr 92 11:56:07 -0400
Received: by uriel.cs.mcgill.ca (NeXT-1.0 (From Sendmail 5.52)/NeXT-2.0)
id AA02630; Tue, 7 Apr 92 11:56:02 EDT
Date: Tue, 7 Apr 92 11:56:02 EDT
From: samurai@uriel.cs.mcgill.ca (Darcy Brockbank)
Message-Id: <9204071556.AA02630@ uriel.cs.mcgill.ca >
Received: by NeXT Mailer (1.63.RR)
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
Add these lines to your .cshrc:
set host="`hostname| sed 's/\..*//'`"
alias mprompt 'set prompt="[$host] [`pwd`] "'
mprompt
- darcy
--
--------------------------------------------------------------------
"You fill in the mortar, I build the wall." "...a secret stigma,
weeping willow, a diminished carnival of sorts." "Who might leave you
where I left off? A perfect circle of acquaintances and friends."
"I can't see myself at thirty I don't buy a lack of thirty
Caught like flies wishing for tomorrow's jewlery" - M. Stipe
From wrb@ulnar Tue Apr 7 10:42:02 1992
Received: from bashful.u.washington.edu by milton.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA13281; Tue, 7 Apr 92 10:41:59 -0700
Received: from ulnar.biostr.washington.edu by bashful.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA18307; Tue, 7 Apr 92 10:41:57 -0700
Received: by ulnar.biostr.washington.edu (NeXT-1.0 (From Sendmail 5.52)/NeXT-2.0 (wrb: 4/2/92))
id AA01473; Tue, 7 Apr 92 10:38:23 PDT
Date: Tue, 7 Apr 92 10:38:23 PDT
From: wrb@ulnar.biostr.washington.edu (Bill Barker)
Message-Id: <9204071738.AA01473@ ulnar.biostr.washington.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
Dave,
Here's what I do. It's a two-step procedure (not unusual for UNIX). First your set the
prompt. That takes care of the first time you open a new shell. Then you change the
behavior of the cd command so when you cd to some other dir, it reflects the new dir
location in the prompt. Put these in your .cshrc file (if you're using csh when in Terminal).
set prompt=${host}:"$cwd> "
alias cd 'cd \!*;set prompt=${host}:"$cwd> " '
Have fun.
bb
--
Bill Barker--Biological Structure--University of Washington--Seattle--WA--98195
(206) 543-7315
From andre@ramsey.cs.laurentian.ca Tue Apr 7 13:14:42 1992
Received: from ramsey.cs.laurentian.ca by milton.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA07118; Tue, 7 Apr 92 13:14:22 -0700
Received: by ramsey.cs.laurentian.ca (5.57/Ultrix3.0-C) id AA13705; Tue, 7 Apr 92 16:13:21 -0400
Date: Tue, 7 Apr 92 16:13:21 -0400
From: andre@ramsey.cs.laurentian.ca (Andre Roberge)
Message-Id: <9204072013.AA13705@ramsey.cs.laurentian.ca>
To: basiji@milton.u.washington.edu
Subject: Re: How do I make shell prompt show working directory?
Newsgroups: comp.sys.next.misc
References: <basiji.702614445@milton>
Status: R
In comp.sys.next.misc 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
Hi there!
You'll probably receive tons of answers on this but
you might want a little addition that I include here...
------------paste in .cshrc-------------
alias SetPrompt 'set prompt="[7m$cwd>[0m "'
alias cd 'cd \!* && SetPrompt'
alias pushd 'pushd \!* && SetPrompt'
alias popd 'popd \!* && SetPrompt'
--------------------------------------
Try this!!
Andre Roberge
From ofi!raul@uunet.UU.NET Tue Apr 7 22:39:13 1992
Received: from relay2.UU.NET by milton.u.washington.edu
(5.65/UW-NDC Revision: 2.22 ) id AA05741; Tue, 7 Apr 92 22:39:11 -0700
Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP
(5.61/UUNET-internet-primary) id AA06376; Wed, 8 Apr 92 01:39:08 -0400
Received: from ofi.UUCP by uunet.uu.net with UUCP/RMAIL
(queueing-rmail) id 013854.20111; Wed, 8 Apr 1992 01:38:54 EDT
Received: by ofi (NeXT-1.0 (From Sendmail 5.52)/NeXT-1.0)
id AA04824; Tue, 7 Apr 92 14:36:22 EDT
Date: Tue, 7 Apr 92 14:36:22 EDT
From: ofi!raul@uunet.UU.NET (Raul Alvarez)
Message-Id: <9204071836.AA04824@ ofi >
To: basiji@milton.u.washington.edu
Subject: Re: How do I make shell prompt show working directory?
Newsgroups: comp.sys.next.misc
In-Reply-To: <basiji.702614445@milton>
Organization: Office of the Future, Inc., Edgewater, N.J.
Cc:
Status: R
Create a shell script with this text and call it .promptset:
--------------------------------------------------------------------------------
set host = "`hostname`"
if ("`alias stripe`" == "") then
alias stripe ""
endif
if ($?term) then
alias promptset 'set prompt = "${host}:${cwd} (\\!)% "'
else
alias promptset 'set prompt = "@${host}:${cwd} (\\!)% "'
endif
alias cd 'cd \!* ; promptset ; stripe'
alias pushd 'pushd \!* ; promptset ; stripe'
alias popd 'popd \!* ; promptset ; stripe'
promptset
--------------------------------------------------------------------------------
In your .cshrc add a line like this:
source .promptset
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads