#!/bin/tcsh -f #(ie run the cshell on this but don't read the .cshrc) # version = 2.10 of nw 2010 Aug 31 # 2010 Aug 31, 2.10 change window information for Mac OS X! # 2010 Aug 31, 2.09 change window information for Mac OS X! - works # 2003 Nov 25, 2.08 change window information # 2003 Nov 10, 2.07 this does not work under Gnome, but vim does it! # 2003 Oct 17, 2.06 begin to prepare for Solaris 5.9 gnome xwindows # 2.05: 2003 Oct 17 quote around $2 to fix bug # 2.04: 2000 Jul 12 -Open and -Closed controls # 2.03: 2000 Jul 11 renamed from 'namewindow' to nw for simplicity # 2.02: 2000 Jun 28 renamed from 'name' to namewindow # 2.01: 1997 Jan 2 previous update # origin before 1995 April 9 # nw: Put a name on a name a Terminal window if ($#argv == 1) then set thename = "$1" else set thename = "" endif if (`uname` == Darwin) then # google: # Mac OS X Terminal window name # http://www.tech-recipes.com/rx/705/mac-os-x-change-the-terminal-window-title/ # this fails: # echo -n -e "\033]0;${thename}\007" # echo -ne "\033]0;${thename}\007" # This works in bash: # bash -c 'echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' # bash -c 'echo -ne "\033]0;${thename}\007"' # This changed the Terminal titlebut failed to show # set QQ = '"' #set mystring = 'echo -ne $QQ\033]0;${thename}@${HOSTNAME}: ${PWD}\007$QQ' setenv tname "$thename" # env | grep name # set mystring = 'echo -ne "\033]0;${tname}@${HOSTNAME}: ${PWD}\007"' set mystring = 'echo -ne "\033]0;${tname} ${USER}@${HOSTNAME}: ${PWD}\007"' bash -c "$mystring" else echo old SunOS window naming method # old sun shelltool information: # from man shelltool # (see also ~toms/script/label.window $1; ~toms/script/label.icon $1) # 2003 Nov 25 # google: xterm change its title # http://www.faqs.org/docs/Linux-mini/Xterm-Title.html # # 3.1 xterm escape sequences # # Window and icon titles may be changed in a running xterm by using # XTerm escape sequences. The following sequences are useful in this # respect: # # * ESC]0;stringBEL -- Set icon name and window title to string # * ESC]1;stringBEL -- Set icon name to string # * ESC]2;stringBEL -- Set window title to string # # where ESC is the escape character (\033), and BEL is the bell # character (\007). # # Printing one of these sequences within the xterm will cause the # window or icon title to be changed. # # THIS DOES NOT WORK!! if `sunos5.9` then # echo sunos5.9 # the following attempt failed 2003 Nov 25 # set open = "$ESC]0$thename$BEL" set ESC = '\033' set BEL = '\007' set ESC = '' set BEL = '' set open = "$ESC]2$thename$BEL" set closed = "$ESC]1$thename$BEL" set open = "${ESC}2;$thename$BEL" set closed = "${ESC}]1;$thename$BEL" set thename = `date` set open = "2;$thename$BEL" echo THERE $open echo -n "\033]0;${USER}@${HOST}\007" exit else set open = "]l$thename\" set closed = "]L$thename\" endif switch ($#argv) case 1: # label the window echo -n "$open" # label the icon of the window echo -n "$closed" breaksw case 2: if ("$2" == "-Open") then #echo set open echo -n $open else if ("$2" == '-Closed') then echo -n "$closed" #echo set closed else echo nw: unrecognized parameter endif endif breaksw default: # 2003 nov 10 remove the \ for sunos5.9 # echo -n "]l \" # echo -n "]L \" echo -n "]l " echo -n "]L " breaksw endsw endif