[SunHELP] Dynamic Xterm Titles using PS1

Will Yardley sunhelp at sunhelp.org
Thu Oct 25 18:28:30 CDT 2001


Seth van buren wrote:
> 
> I have checked the Min howtoos and the Xterm FAQ site.  They all give
> a method that uses escape charactes in the Prompt String (PS1).
> However I have found this to have no effect, other that when the
> prompt is first set.

zsh is really good at this; i use:
case $TERM in
        rxvt*|xterm*)
                precmd () {print -Pn "\e]2;%n@%m%#  %~ %l  %w :: %T\a"}
                preexec () {print -Pn "\e]2;%n@%m%#  <$1>  %~ %l  %w ::
%T\a"}
        ;;
esac

bash, something like this should work:

TITLEBAR='\[\033]0;\u@\h: \w \s: \d \t\007\]'
case $TERM in
        xterm*)
PS1="${TITLEBAR}\
\h\
 \$ "
        ;;
        *)
                PS1='\u@\h $ '

since ksh is similar to other bourne like shells, something like the
second bit should work.  zsh can emulate ksh and has better features for
exporting your prompt to the titlebar.

i've never had any problems with bash or zsh not changing the prompt
properly when directory changes.

w

-- 
GPG Public Key:
http://infinitejazz.net/will/pgp/



More information about the SunHELP mailing list