carroll@m.cs.uiuc.edu (02/22/90)
Here's my entry for the changing Xterm titles. Features of this system:
+ It's not in your prompt, so there's no annoying flicker when you're not
changing directories.
+ It uses relative path names, so when you're in your home directory area,
the path name is shorter (for some of us, _much_ shorter).
+ You can put leading headings in the title (and it would be trivial to
add trailing ones).
+ You can inhibit the title changes.
+ You can put the PRWD variable in your prompt if you want, and get the
relative path name there.
- It requires Korn Shell.
You can put a leading title (such as "Console: " for your console xterm) by
using (e.g., in your .xinitrc)
XTITLE='Console: ' xterm ...
You can inhibit the change by using
NOXTITLE=true xterm ...
Put this in your .profile:
HOST=$(hostname) ; HOST=${HOST%%.*} ; export HOST
export PRWD="~"
export XTITLE=""
and this in your ENV file:
# <ESC> ] 0 ; string <BEL> and string will become the title and icon name
# <ESC> ] 1 ; string <BEL> for icon name only
# <ESC> ] 2 ; string <BEL> for title name only
XPRE="]0;" # There's a raw escape in here
XPOST="" # and a raw control-G here
function CD
{
\cd $@
PRWD=${PWD##${HOME}}
if [ ! "${PRWD}" = "${PWD}" ] ; then
PRWD="~$PRWD"
fi
if [ "$TERM" = "xterm" -a -z "$NOXTITLE" ] ; then
print -n -r "${XPRE}${XTITLE}${PRWD}@${HOST}${XPOST}"
fi
}
alias cd=CD
CD . # force update at the start
# have to fix rlogin and telnet so that they reset the title afterwards
# set the functions indirectly with eval so that we can grab the current
# whence value, and set it permanently.
# in case we've already done this, we need to blow off any previous definitions
unset -f telnet
unset -f rlogin
fred="function telnet { $(whence telnet) \$@ ; cd . ; }"
eval "$fred"
fred="function rlogin { $(whence rlogin) \$@ ; cd . ; }"
eval "$fred"
unset fred
#
Alan M. Carroll "I hold the line - The line of strength
carroll@cs.uiuc.edu that pulls me through the fear.
Conversation Builder: San Jacinto - I hold the line
+ Tomorrow's Tools Today + San Jacinto - Poison bite and
Epoch Development Team Darkness take my sight -I hold the line."
CS Grad / U of Ill @ Urbana ...{ucbvax,pur-ee,convex}!cs.uiuc.edu!carroll