🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1666

Re: Built-in String Processing?

#1666
From: Boyd Roberts
Date: Mon, 29 Oct 1990 23:00
36 lines
1250 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...
>

With a decent* shell you just go:

    cd()
    {
	builtin cd $1 &&
	case "$1" in
	'')
	    PS1="% " ;;
	..|*/..)
	    PS1="`basename \`/bin/pwd\``% " ;;
	/)
	    PS1="/% " ;;
	*/*)
	    PS1="`basename $1`% " ;;
	*)
	    PS1="$1% " ;;
	esac
    }



Boyd Roberts			boyd@necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''

* V8/V9
Technical Details
Message-ID: <1902@necisa.ho.necisa.oz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!metro!cluster!necisa!boyd
References: <1990Oct27.215051.14085@midway.uchicago.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!metro!cluster!necisa!boyd
From: boyd@necisa.ho.necisa.oz (Boyd Roberts)
Newsgroups: comp.unix.shell
Subject: Re: Built-in String Processing?
Message-ID: <1902@necisa.ho.necisa.oz>
Date: 29 Oct 90 23:00:18 GMT
References: <1990Oct27.215051.14085@midway.uchicago.edu>
Organization: NEC Information Systems Australia Pty. Ltd.
Lines: 36