Unix Articles |
|||||||
|---|---|---|---|---|---|---|---|
|
HOME Object Libraries ctags Tree Climbing |
|||||||
|
Updating The xterm Title BarThe following script is based on a letter by Michael J. Hammel in the January 1997 edition of the Linux Journal. If this code is added to a ".kshrc" (for Korn shell) or ".bashrc" (for bash) file, it will update the title bar on the xterm client with the current host system's name, and the path. If the current path is below $HOME, the $HOME portion will be removed from the path. If "vi" is in use, the titlebar will display "vi [filename]" where [filename] is the name of the file being edited.
# Script to set title of terminal window
HOSTNAME=`uname -n`
if [ "$TERM" = "xterm" ]
then
ilabel () { /bin/echo "^[]1;$*^G\c"; }
label () { /bin/echo "^[]2;$*^G\c"; }
alias stripe='label $HOSTNAME - ${PWD#$HOME/}'
alias stripe2='label $HOSTNAME - vi $*'
cds ()
{
if [ -z "$1" ]
then
"cd"
else
"cd" $*
fi
eval stripe;
}
vis () { eval stripe2; "vi" $*; eval stripe; }
alias cd=cds
alias vi=vis
eval stripe
eval ilabel "$HOSTNAME"
fi
Note: Two small changes will be necessary after this text is cut & pasted. Replace the "^[" characters in the "label()" and "ilabel()" definitions with escape characters. This can be done in "vi" by typing "i" (for insert mode) and then [ctrl-v][esc]. In addition, the "^G" characters will need to be replaced by [ctrl-g]. Once again this can be done in insert mode using [ctrl-v][ctrl-g]. |
||||||
|
HOME Object Libraries ctags Tree Climbing |
|||||||