🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1657

Re: Built-in String Processing?

#1657
From: Kurt Hirchert
Date: Mon, 29 Oct 1990 16:03
32 lines
2104 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?

The following is copied from my .cshrc .  On machines where I work regularly
under other directories, I include other sed substitutions.  The alias for
setprompt doesn't really need to be on three lines; it was organized this way
for purposes of inclusion in one of our local publications where really long
lines did not display well.  (Note that the quoting is set up to evaluate
hostname at the time the alias is defined, but to defer evaluation of of the
pwd/sed pipe until the alias is executed.)

# aliases for changing the prompt to include current directory
alias setprompt	'set prompt="("`pwd |'\
'sed -e "s|^$home|~|"'\
'`") "'\""`hostname` \\!% "\"
alias cd	"cd \!* ; setprompt"
alias chdir	"chdir \!* ; setprompt"
alias pushd	"pushd \!* ; setprompt"
alias popd	"popd \!* ; setprompt"
--
Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications
Technical Details
Message-ID: <1990Oct29.160325.23250@ux1.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!sun-barr!cs.utexas.edu!usc!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!harriett!hirchert
References: <1990Oct27.215051.14085@midway.uchicago.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!sun-barr!cs.utexas.edu!usc!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!harriett!hirchert
From: hirchert@harriett.ncsa.uiuc.edu (Kurt Hirchert)
Newsgroups: comp.unix.shell
Subject: Re: Built-in String Processing?
Message-ID: <1990Oct29.160325.23250@ux1.cso.uiuc.edu>
Date: 29 Oct 90 16:03:25 GMT
References: <1990Oct27.215051.14085@midway.uchicago.edu>
Sender: news@ux1.cso.uiuc.edu (News)
Reply-To: hirchert@harriett.ncsa.uiuc.edu (Kurt Hirchert)
Organization: National Center for Supercomputing Applications
Lines: 32