prompt changing on the fly
davy at pur-ee.UUCP
davy at pur-ee.UUCP
Fri Jan 30 13:15:07 AEST 1987
In article <104 at titn.TITN> herve at 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
More information about the Comp.unix.wizards
mailing list