Built-in String Processing?

Carl Edman cedman at lynx.ps.uci.edu
Sun Oct 28 13:20:51 AEST 1990


In article <1990Oct27.215051.14085 at midway.uchicago.edu> phd_ivo at 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 at golem.ps.uci.edu
in the laboratory.                           | edmanc at uciph0.ps.uci.edu



More information about the Comp.unix.shell mailing list