Article View: comp.sys.next.misc
Article #836Re: How do I make shell prompt show working directory?
From: 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!
Technical Details
Message-ID:
<SCOTT.92Apr7143253@nic.gac.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!olivea!spool.mu.edu!umn.edu!noc.MR.NET!gacvx2.gac.edu!gacvax2!scottReferences:
<basiji.702614445@milton> <1992Apr7.072725.6379@nextdoor.com><1992Apr7.120605. 26841@macc.wisc.edu><1992Apr07.145433.53171@cs.cmu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!spool.mu.edu!umn.edu!noc.MR.NET!gacvx2.gac.edu!gacvax2!scott From: scott@nic.gac.edu (Scott Hess) Newsgroups: comp.sys.next.misc Subject: Re: How do I make shell prompt show working directory? Message-ID: <SCOTT.92Apr7143253@nic.gac.edu> Date: 7 Apr 92 19:32:53 GMT References: <basiji.702614445@milton> <1992Apr7.072725.6379@nextdoor.com><1992Apr7.120605. 26841@macc.wisc.edu><1992Apr07.145433.53171@cs.cmu.edu> Organization: Gustavus Adolphus College Lines: 77 Nntp-Posting-Host: nic.gac.edu In-reply-to: cmaeda+@cs.cmu.edu's message of 7 Apr 92 14:54:33 GMTLines: 77