Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cuae2!ihnp4!inuxc!pur-ee!davy From: davy@pur-ee.UUCP Newsgroups: comp.unix.wizards Subject: Re: prompt changing on the fly Message-ID: <5355@pur-ee.UUCP> Date: Thu, 29-Jan-87 22:15:07 EST Article-I.D.: pur-ee.5355 Posted: Thu Jan 29 22:15:07 1987 Date-Received: Sat, 31-Jan-87 04:19:19 EST References: <410@moncskermit.oz> <104@titn.TITN> Reply-To: davy@pur-ee.UUCP (Dave Curry) Organization: Electrical Engineering Department , Purdue University Lines: 39 In article <104@titn.TITN> herve@titn.TITN (Herve Siegrist) writes: > > alias cd 'set old=$cwd; chdir \!*; set prompt = "$Ndirs$cwd> "' > alias back 'set back=$old; set old=$cwd; cd $back; unset back' > alias ndir "dirs|wc|sed -e 's/^ *1 *//' -e 's/ .*//'" > alias push 'pushd \!*; set Ndirs="`ndir` - "; cd .' > alias pop 'popd \!*; set Ndirs="`ndir` - "; cd .' > set Ndirs = "`ndir` - " > cd . > I've seen lots of these "back" aliases, and never really understood why. The "pushd" command, if given no arguments, pops the directory stack and pushes the current directory, thus effectively doing exactly the same thing without all the shell variables. For example, my .cshrc (it's in .cshrc because suntools doesn't run "-csh" and so .login won't get run in windows) has: if ($?prompt) then set cpu = `hostname | sed -e 's/\.*//'` alias cd chdir \!:\* \; set prompt='${cpu}:${cwd}\[!\]\ ' alias pd pushd \!:\* \; set prompt='${cpu}:${cwd}\[!\]\ ' alias pp popd \!:\* \; set prompt='${cpu}:${cwd}\[!\]\ ' cd . endif which gives me a prompt with the current hostname (minus the domains, which in our case is ".ecn.purdue.edu", a little long), the current directory, and the history number in brackets, as in: intrepid:/usr/harbor/davy[23] To change directories I just do "pd newdir", to pop I just do "pp", and to bounce between two directories, I just do "pd". --Dave Curry