Prompt changing on the fly - Oops
Eric Flink
eric at hpfcda.HP.COM
Thu Jan 22 03:38:30 AEST 1987
I like having my current directory name appear in my prompt.
The following aliases appear in my .cshrc file:
set prompt="(\! $cwd:t) % "
alias cd 'set cdmark=$cwd; chdir \!* ; set prompt="(\! $cwd:t) % "'
alias pushd 'pushd \!* ; set prompt="(\! $cwd:t) % "'
alias popd 'popd; set prompt="(\! $cwd:t) % "'
Note: the :t modifier appended to $cwd strips all but the last
element of the path name. (Otherwise your prompt might get very
long!) I didn't invent these aliases, someone posted the idea
to USENET some time back.
Using the Korn shell, you can do the same thing with the following:
PS1="(! \${PWD##*/}) $ "
export PS1
More information about the Comp.unix.questions
mailing list