Article View: comp.unix.shell
Article #1640Re: Built-in String Processing?
From: Carl Edman
Date: Sun, 28 Oct 1990 02:20
Date: Sun, 28 Oct 1990 02:20
37 lines
2461 bytes
2461 bytes
In article <1990Oct27.215051.14085@midway.uchicago.edu> phd_ivo@gsbacd.uchicago.edu writes:
I am running a csh with enhancements on my NeXT and on an HP-9000/8xx.
I have a macro to define my prompt to be the current directory, i.e.
alias cd 'cd \!* && set prompt="\! ${cwd}> "'
Unfortunately, this gives me a rather long string, which starts with
'/Users/u/ivo/subdir' etc. I would like to get rid of the first x characters of
the ${cwd} variable in this macro, i.e. display only 'subdir' ( or even better,
only if the string starts with '/Users/u/ivo' ). How would I do this?
Well, if you have any choice over your shell , you should have no problems
installing 'tcsh' instead. It is largly compatible and offers many neat
features csh doesn't have. Among these is the ability to set your prompt
to e.g. "%~> " (like I have). This will give you a full path if you are
somewhere outside your home directory, but if you are in it the entire path
to it will be replaced by "~" (logical, isn't it ?). i.e. if you are in
$HOME/Mail the prompt in the above example would be "~/Mail> ". If you
were in "/usr/local/lib/mh" the prompt would be "/usr/local/lib/mh> ".
This is only of the least of the many nice features of this shell. I
use it on most machines.
You can get a copy of the source to tcsh 5.19 (and maybe even a NeXT
executable) from "tesla.ee.cornell.edu". But beware: If you won't to
get a complete source for tcsh you will also have to have the source
to BSD 4.3 csh. Or maybe I kind soul somewhere on the net could take
pity to your plight (:-) and send you a complete source, if you can't
get the BSD 4.3 csh source.
Carl Edman
Theorectial Physicist,N.:A physicist whose | Send mail
existence is postulated, to make the numbers | to
balance but who is never actually observed | cedman@golem.ps.uci.edu
in the laboratory. | edmanc@uciph0.ps.uci.edu
Technical Details
Message-ID:
<CEDMAN.90Oct27192056@lynx.ps.uci.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!cedmanReferences:
<1990Oct27.215051.14085@midway.uchicago.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!usc!orion.oac.uci.edu!cedman From: cedman@lynx.ps.uci.edu (Carl Edman) Newsgroups: comp.unix.shell Subject: Re: Built-in String Processing? Message-ID: <CEDMAN.90Oct27192056@lynx.ps.uci.edu> Date: 28 Oct 90 02:20:51 GMT References: <1990Oct27.215051.14085@midway.uchicago.edu> Organization: non serviam Lines: 37 Nntp-Posting-Host: lynx.ps.uci.edu In-reply-to: phd_ivo@gsbacd.uchicago.edu's message of 27 Oct 90 21:45:33 GMT