Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!rutgers!clyde!cbatt!cwruecmp!hal!ncoast!tdi2!brandon From: brandon@tdi2.UUCP (Brandon Allbery) Newsgroups: net.sources Subject: Re: Prompt Wars Message-ID: <338@tdi2.UUCP> Date: Mon, 13-Apr-87 14:07:18 EST Article-I.D.: tdi2.338 Posted: Mon Apr 13 14:07:18 1987 Date-Received: Tue, 21-Apr-87 03:47:05 EST References: <5983@dartvax.UUCP> Reply-To: brandon@tdi2.UUCP (Brandon Allbery) Followup-To: net.sources Distribution: world Organization: Tridelta Industries, Inc., Mentor, Ohio Lines: 117 Don't you think this is getting a bit ridiculous? BTW, here's mine, for a csh such as Xenix and System III/V resellers like to include: (change paths as necessary) ------------------------------------------------------------------------------- if ("`/usr/plx/printenv CSHLEVEL`" == "") then setenv CSHLEVEL 1 setenv CSHTYPE "" set cwd=(`/bin/pwd`) else if ($?prompt) then @ level=$CSHLEVEL + 1 setenv CSHLEVEL $level set uid=`/appl/u32/bin/uid` # well, it's easiest if ($uid == 0) then set w=\# else set w=\% endif if ( "$CSHTYPE" == "" ) then set prompt="${level}${w} " else set prompt="$CSHTYPE@${level}${w} " endif unset level w set cwd=(`/bin/pwd`) endif ------------------------------------------------------------------------------- Change the reference to the "uid" program; I used to use "id" through a sed command, but I have to admit that the above is faster... (u32 == UNIFY 3.2) This works with the following, which is VERY useful (dunno how useful if you have sxt's or job control; we have neither) for preserving environments: ------------------------------------------------------------------------------- #! /bin/sh # # Generate a new environment and run a subshell with it. $1 names the # environment file to be used. # [ $# -gt 1 ] && { echo "usage: $0 [environment]" >&2 exit 1 } [ $# -eq 0 ] && exec ${SHELL:-/bin/sh} envspec="$HOME/.pushenv/$1" [ -f "$envspec" ] || { echo "$0: Unknown environment." >&2 exit 1 } env | fgrep "PATH HOME TERM TZ CSHLEVEL CSHTYPE EDITOR LOGNAME MAIL SHELL" | fgrep -v "`sed -n '/^!/s///p' < $envspec`" > /tmp/env.$$ env | fgrep "`sed -n '/^=/s///p' < $envspec`" >> /tmp/env.$$ ed - /tmp/env.$$ << eof g/=/s/=\(.*\)$/='\1'/ w q eof sed -f /u/brandon/.pushenv/.push.sed < $envspec >> /tmp/env.$$ # cat /tmp/env.$$ env="`sed -n '/^cd/!s/=.*//p' < /tmp/env.$$`" unset `env | sed -n '/^PATH=/!s/=.*//p'` . /tmp/en[vw].$$ export $env /bin/rm -f /tmp/env.$$ # echo '---' # exec env exec ${SHELL:-/bin/sh} ------------------------------------------------------------------------------- This is used with files in ~/.pushenv containing lines of the following form: ------------------------------------------------------------------------------- # # Environment for UNICOE # @UNICOE # ID to put in prompt $UNIFY = /appl/u32/lib # set some useful environment variables $BUDEV = /dev/rrm/0m $DBPATH = /coesys/bin $UUID = 0 $UUACL = 15 $DATETP = US $PATH = $DBPATH:$UNIFY/../bin:$PATH $EDIT = $EDITOR >$DBPATH # and change directory ------------------------------------------------------------------------------- By default a small set of environment variables is retained and the rest are junked, so you can start out "clean" on each "push". (I also alias "pop" to "exit".) RV and the like in the prompt? Well, there's always "tput" under System V. Hopefully this article has a little more useful "meat" than the previous ones. (Of course, ``meat'' is relative; we don't use hostnames (1 machine), I don't want the current directory in my prompt and dislike flashing lights except to flag disasters.) ++Brando -- Brandon S. Allbery UUCP: cbatt!cwruecmp!ncoast!tdi2!brandon Tridelta Industries, Inc. CSNET: ncoast!allbery@Case 7350 Corporate Blvd. INTERNET: ncoast!allbery%Case.CSNET@relay.CS.NET Mentor, Ohio 44060 PHONE: +1 216 255 1080 (home +1 216 974 9210)