krishnan@vicom.com (Hari Krishnan Krishna) (12/05/90)
Is there a way to display the current directory in the title bar of the xterm. Any help appreciated. Krishna
carroll@cs.uiuc.edu (Alan M. Carroll) (12/06/90)
This is the code that I use under ksh (88d). If you set XTITLE to a value, that
will preceed the directory name. This is handy for the console.
#!/bin/ksh
# XTerm title updating
# <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
# The following have been edited to remove raw control characters. To make this
# work, replace ^[ with an actual ESCAPE character, and ^G with an actual
# control G.
XTITLEPRE="^[]2;"
XICONPRE="^[]1;"
XPOST="^G"
unalias cd
function CD
{
\cd $@
PRWD=${PWD##${HOME}}
if [ ! "${PRWD}" = "${PWD}" ] ; then
PRWD="~$PRWD"
fi
if [[ "$TERM" = "xterm" && "$NOXTITLE" = "" ]] ; then
print -n -r "${XTITLEPRE}${XTITLE}${PRWD}@${HOST}${XPOST}"
fi
}
alias cd=CD
--
Alan M. Carroll "It's psychosomatic. You need a lobotomy.
Epoch Development Team I'll get a saw."
CS Grad / U of Ill @ Urbana ...{ucbvax,pur-ee,convex}!cs.uiuc.edu!carroll
SPLITE@MTUS5.BITNET (12/07/90)
In article <1990Dec5.014338.22560@vicom.com>, krishnan@vicom.com (Hari Krishnan Krishna) says: > >Is there a way to display the current directory in the title bar of the >xterm. > >Any help appreciated. > >Krishna It's possible using an xterm escape sequence and C-Shell aliases. Put the following in your .cshrc: alias cd '\!\!;echo -n "<ctrl-v><esc>]0;$PWD<ctrl-g>"' alias pushd '\!\!;echo -n "<ctrl-v><esc>]0;$PWD<ctrl-g>"' alias popd '\!\!;echo -n "<ctrl-v><esc>]0;$PWD<ctrl-g>"' Of course, <ctrl-v> means "press ctrl-v", etc. I'm not sure how "official" that escape sequence is, but it works for us. Steve Plite <splite@mtu.edu>
graham@fuel.dec.com (graham) (12/11/90)
> Subject: Current directory in the title bar.. > Date: 5 Dec 90 01:43:38 GMT > > Is there a way to display the current directory in the title bar of the > xterm. Try the following with a C Shell. Tested on RISC/ULTRIX only. if (! $?0) then # we've been run from a login session echo running .cshrc # if ($?TERM) then if ($TERM == xterm) then stty dec echo "initializing xterm" # # save our hostname # setenv HOSTNAME `hostname` # # update the title right now # echo -n "]0;"${HOSTNAME}"::"${cwd}"" # # alias to set the title freely # alias title 'echo -n "]0;"\!*"" ' # # alias cd, pushd, popd to update the title bar with dir and host # alias cd 'cd \!*; echo -n "]0;"${HOSTNAME}":"${cwd}"" ' alias pushd 'pushd \!*; echo -n "]0;"${HOSTNAME}":"${cwd}"" ' alias popd 'popd \!*; echo -n "]0;"${HOSTNAME}":"${cwd}"" ' alias rlogin 'echo -n "]0;"\!*":";/usr/ucb/rlogin \!*; echo -n "]0;"${HOSTNAME}":"${cwd}"" ' endif # Christopher Graham Internet: graham@fuel.enet.dec.com Digital Equipment Corp UUCP: ...!decwrl!fuel.enet.dec.com!graham Ultrix Resource Center New York City