Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!utah-cs!utah-gr!thomas From: thomas@utah-gr.UUCP (Spencer W. Thomas) Newsgroups: net.unix-wizards Subject: Re: CSH script help needed Message-ID: <1045@utah-gr.UUCP> Date: Mon, 9-Jan-84 21:47:17 EST Article-I.D.: utah-gr.1045 Posted: Mon Jan 9 21:47:17 1984 Date-Received: Tue, 10-Jan-84 05:46:30 EST References: sri-arpa.15094 Lines: 40 1. The "plugh" command you show is pretty well covered by the pushd command in 4bsd and later c-shells. If you are still in v7-land, the following should do it: alias plugh 'if ( "\!*" == "" ) cd $prevdir;'\ 'if ( "\!*" != "" ) cd \!*;'\ 'set prevdir = $cwd' alias cd 'cd \!*; set cwd=`pwd`' 2. To get your current directory in the prompt, the following aliases will do it (assuming 4bsd csh, which automatically sets the cwd variable): alias cd 'cd \!*; setprompt' alias pd 'pushd \!*; setprompt' alias popd 'popd \!*; setprompt' set baseprompt = bbna alias setprompt 'set prompt="$baseprompt $cwd >"' A slightly fancier version takes into account your favorite csh variables to abbreviate the directory name: alias sortset source ~/bin/sortset set baseprompt = "$prompt:q" alias setprompt 'set prompt="["`echo $cwd | sed -f ~/.set`"]$baseprompt:q"' This gives a prompt like [$foo/bar] utah-gr> The sortset script is given below. It contains as special cases a few variables that I do NOT want to see in my prompt. set | awk '/^ds/ { next; }\ /^old/ { next; }\ /^cwd/ { next; }\ / \// { if (NF == 2) print length($2), $0; }\ { next; }' | sort -rn |\ awk '{ if ($3 != "'${HOME}'") printf "s;%s;$%s;\n", $3, $2; }\ END { print "s;'${HOME}';~;"; }' >~/.set =Spencer