Thread View: comp.sys.next.misc
6 messages
6 total messages
Started by David Basiji
Tue, 07 Apr 1992 02:40
How do I make shell prompt show working directory?
Author: David Basiji
Date: Tue, 07 Apr 1992 02:40
Date: Tue, 07 Apr 1992 02:40
8 lines
609 bytes
609 bytes
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
Re: How do I make shell prompt show working directory?
Author: John McCracken
Date: Tue, 07 Apr 1992 07:27
Date: Tue, 07 Apr 1992 07:27
28 lines
1390 bytes
1390 bytes
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
Re: How do I make shell prompt show working directory?
Author: Jess Anderson
Date: Tue, 07 Apr 1992 12:06
Date: Tue, 07 Apr 1992 12:06
64 lines
2703 bytes
2703 bytes
In article <1992Apr7.072725.6379@nextdoor.com>
john@nextdoor.com (John McCracken) writes:
>I use /bin/csh as the default shell, and here's what I have
>in my .login file:
>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.
Bearing in mind that this prompt business is (periodically)
a topic more appropriate to comp.unix.questions, here's
another variant:
alias cd 'cd \!*; doprompt'
alias doprompt 'set prompt="[`hostname`:`whoami`]`dirs|sed -e
'\''s/ //'\'' -e 's.~..' -e 's./..'`[\\!] "'
where the doprompt alias is all one line and .cshrc ends with
a doprompt command. A sample result is:
[yak:anderson]Network/Wiscnet/Statistics/Data/RawData[43]
Where I really am at this point is:
/Users/anderson/Network/Wiscnet/Statistics/Data/RawData
One of these days I'll get around to refining this a little, so
as to shorten the prompt by replacing the middle of the path
with an ellipsis ... like this:
[yak:anderson]Network/.../RawData[43]
A further improvement would be to show the front end of the
path when I'm not in my home directory:
[yak:anderson]/NextApps/Installer.app[49]
rather than
[yak:anderson]NextApps/Installer.app[49]
Having both the nostname and the login name is useful to me
because (being a network person), I'm usually on three or
four machines simultaneously (they have similar prompt
settings [just sort-of in the case of the VMS critters]),
and I'm sometimes also running as some other user (notably
root). root's .cshrc adds the usual # in the prompt string
as an *extra* reminder (I'm not bright, though I am
persistent, so I can use more than one reminder :-).
Playing with these things can be a *major* antiproductivity
tool, though nothing I've run into beats Fractint in that
regard.
--
Jess Anderson <> Madison Academic Computing Center <> University of Wisconsin
Internet: anderson@macc.wisc.edu <-best, UUCP:{}!uwvax!macc.wisc.edu!anderson
NeXTmail w/attachments: anderson@yak.macc.wisc.edu Bitnet: anderson@wiscmacc
Room 3130 <> 1210 West Dayton Street / Madison WI 53706 <> Phone 608/262-5888
Re: How do I make shell prompt show working directory?
Author: Christopher Maeda
Date: Tue, 07 Apr 1992 14:54
Date: Tue, 07 Apr 1992 14:54
38 lines
2016 bytes
2016 bytes
In article <1992Apr7.120605.26841@macc.wisc.edu> anderson@macc.wisc.edu (Jess Anderson) writes: > >In article <1992Apr7.072725.6379@nextdoor.com> >john@nextdoor.com (John McCracken) writes: > >Bearing in mind that this prompt business is (periodically) >a topic more appropriate to comp.unix.questions, here's >another variant: > > alias cd 'cd \!*; doprompt' > alias doprompt 'set prompt="[`hostname`:`whoami`]`dirs|sed -e >'\''s/ //'\'' -e 's.~..' -e 's./..'`[\\!] "' > That's disgusting. Why do people think firing up sed with line noise for arguments every time you change your working directory is elegant? "Many small tools..." "Thousand points of light..." You also have to alias pushd and popd. Another solution to this problem is to use tcsh or bash which both let you put the working directory in the prompt by saying something simple like (this works for bash) PS1="\h \w : " "\h" is replaced with the host name. "\w" is replaced with the working directory. This gives the following prompt: MC8 ~/News : It also updates it automatically when the working directory changes. -- Chris Maeda, Grad Student and RetroGrouch <cmaeda@cs.cmu.edu> "A unix signature isn't a return address, it's the ASCII equivalent of a black velvet clown painting. It's a rectangle of carets surrounding a quote from a literary giant of weeniedom like Heinlein or Dr. Who."
Re: How do I make shell prompt show working directory?
Author: Scott Hess
Date: Tue, 07 Apr 1992 19:32
Date: Tue, 07 Apr 1992 19:32
77 lines
4120 bytes
4120 bytes
In article <1992Apr07.145433.53171@cs.cmu.edu>
cmaeda+@cs.cmu.edu (Christopher Maeda) writes:
>In article <1992Apr7.120605.26841@macc.wisc.edu>
>anderson@macc.wisc.edu (Jess Anderson) writes:
>>
>>In article <1992Apr7.072725.6379@nextdoor.com>
>>john@nextdoor.com (John McCracken) writes:
>>
>>Bearing in mind that this prompt business is (periodically)
>>a topic more appropriate to comp.unix.questions, here's
>>another variant:
>>
>> alias cd 'cd \!*; doprompt'
>> alias doprompt 'set prompt="[`hostname`:`whoami`]`dirs|sed -e
>>'\''s/ //'\'' -e 's.~..' -e 's./..'`[\\!] "'
>
>That's disgusting. Why do people think firing up sed with line
>noise for arguments every time you change your working directory
>is elegant? "Many small tools..." "Thousand points of light..."
>
>You also have to alias pushd and popd.
I would say, rather, that it's an interesting use of the tools at
hand. But, it is still futile, because there are better tools out
there availiable for _free_.
>Another solution to this problem is to use tcsh or bash which both let
>you put the working directory in the prompt by saying something simple
If you don't have a decent shell program _go_get_one_ (This post
contains a subliminal message, you can't help it, you are now being
forced to use archie and find it ...).
tcsh has _excellent_ facilities for setting up decent prompts. In
fact, that's the reason why I haven't changed shells, even though
there are a couple out there that are still tempting (esp. the rc
shell - rc is _fast_, when I was running it on a trial basis, the
shell was ready when the Stuart window was, instead of having to
wait a couple seconds). For instance, from the end of my .cshrc
(run under tcsh):
set prompt="%m:%C2%#%{^[]0;%m@%/ (%l)^G%} "
This little line sets my prompt to the section of the hostname
before the first '.' character (so, on holstein.bovine.gov, that
would be holstein alone), followed by a ':' character, followed by
the last two segments of the pathname (in directory /Users/scott/Work
this would be scott/Work, while in /Users/scott, this would be
/Users/scott) followed by '>' for regular accounts and '#' for root
accounts, followed by ' ' at the end.
Well, there's a sequence in there that bears elaboration.
"%{^[]0;%m@%/ (%l)^G%}" also sends an escape sequence to Stuart
that sets this window's titlebar to the first part of the hostname
followed by '@' followed by the pathname followed by the tty port
in parenthesis. Of course, that section will not work on the Stuart
that most of you have - it's sort of an in-development thing. But,
I just had to include that to demonstrate that tcsh allows for very
potent prompts.
tcsh-6.01 is AT&T _free_. It's basically under the Berkeley
CopyMiddle license, which means that it really is free. I don't
remember it taking much to compile, and a number of people I know
have asked me how to compile it and answered their own question
before I got back to them. Sorry I can't tell you where to get it
from - use archie to find out. On an Internetworked Unix box, run:
rlogin quiche.cs.mcgill.ca -l archie
And you are in. Else, you can telnet to quiche and enter the archie
username directly. There's help on the system. Else, get NeXTArchie
from the archives :-).
Later,
--
scott hess <scott@gac.edu> <A GUI is to a command-line as a TV is to a book>
12901 Upton Avenue South, #326 Burnsville, MN 55337 (612) 895-1208 Anytime!
Re: How do I make shell prompt show working directory?
Author: Jess Anderson
Date: Wed, 08 Apr 1992 00:53
Date: Wed, 08 Apr 1992 00:53
35 lines
1886 bytes
1886 bytes
In article <1992Apr07.145433.53171@cs.cmu.edu>
cmaeda+@cs.cmu.edu (Christopher Maeda) writes:
>In article <1992Apr7.120605.26841@macc.wisc.edu>
>anderson@macc.wisc.edu (Jess Anderson) writes:
>> alias cd 'cd \!*; doprompt'
>> alias doprompt 'set prompt="[`hostname`:`whoami`]`dirs|sed -e
>>'\''s/ //'\'' -e 's.~..' -e 's./..'`[\\!] "'
>That's disgusting. Why do people think firing up sed with
>line noise for arguments every time you change your working
>directory is elegant? "Many small tools..." "Thousand
>points of light..."
Well, now that you mention it, you *do* sound a little like
George Bush. But I'm a forgiving kind of guy, and I'm using
the shell I'm using, so you be forgiving too and we'll have
our separate ways.
>You also have to alias pushd and popd.
Did that, thought it was obvious. So what?
>-- Chris Maeda, Grad Student and RetroGrouch
Not to worry, it's a sorry state that doesn't last forever
(believe me, I was in college for 15 years!).
--
Jess Anderson <> Madison Academic Computing Center <> University of Wisconsin
Internet: anderson@macc.wisc.edu <-best, UUCP:{}!uwvax!macc.wisc.edu!anderson
NeXTmail w/attachments: anderson@yak.macc.wisc.edu Bitnet: anderson@wiscmacc
Room 3130 <> 1210 West Dayton Street / Madison WI 53706 <> Phone 608/262-5888
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