Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ucla-cs!sdcrdcf!trwrb!simpson From: simpson@trwrb.UUCP Newsgroups: net.sources Subject: Re: Prompt wars, revisited. Message-ID: <1744@trwrb.UUCP> Date: Thu, 2-Apr-87 08:25:56 EST Article-I.D.: trwrb.1744 Posted: Thu Apr 2 08:25:56 1987 Date-Received: Sun, 5-Apr-87 01:03:52 EST References: <300@cpro.UUCP> <1500@umd5.umd.edu> <65@esquire.UUCP> Reply-To: simpson@trwrb.UUCP (Scott Simpson) Distribution: world Organization: TRW EDS, Redondo Beach, CA Lines: 87 Here are an implementation of pushd and popd in the Korn shell that I put in a file .kshrc. I also use sysline(1) and put the prompt in the bottom of the terminal screen by writing to the .who file. dirstack= function chdir { integer cutoff \cd $@ || return 1 let cutoff="${#HOME} + 1" if [ "`pwd | colrm $cutoff`" = ~ ]; then echo \~`pwd | colrm 1 ${#HOME}` > ~/.who # .who is read by sysline(1) else pwd > ~/.who fi } alias cd=chdir alias back='chdir -' function pushd { integer cutoff if [ $# -ne 1 ]; then return 1 fi chdir $1 || return 1 let cutoff="${#HOME} + 1" dirstack="$OLDPWD $dirstack" for i in `pwd` $dirstack; do if [ "`echo $i | colrm $cutoff`" = ~ ]; then echo -n "~`echo $i | colrm 1 ${#HOME}` " else echo -n "$i " fi done echo } function popd { integer cutoff if [ $# -ne 0 ]; then return 1 fi set -- $dirstack if [ $# -le 0 ]; then echo Directory stack empty return 1 fi chdir $1 || return 1 let cutoff="${#HOME} + 1" shift dirstack=$* if [ "`pwd | colrm $cutoff`" = ~ ]; then echo \~`pwd | colrm 1 ${#HOME}` else pwd fi } function dirs { integer cutoff let cutoff="${#HOME} + 1" for i in `pwd` $dirstack; do if [ "`echo $i | colrm $cutoff`" = ~ ]; then echo -n "~`echo $i | colrm 1 ${#HOME}` " else echo -n "$i " fi done echo } This file gets read on Korn shell invocation by putting the lines ENV=~/.kshrc export ENV . $ENV in my .profile. I also add the lines echo \~ > .who sysline -Dqj to invoke sysline in my .profile. -- Scott Simpson TRW Electronics and Defense Sector ...{decvax,ihnp4,ucbvax}!trwrb!simpson