2 # customization parameters
3 #ttyprefix=/dev/tty ;# what to add to ttycolumn's word to obtain valid device
4 ttyprefix=/dev/; #for linux systems with /dev/pts
5 cmdcolumn=4 ;# where to find command in ps output
6 ttycolumn=2 ;# where to find tty name in ps output
8 # displays usage information
10 echo "xtitle [ -t tty|-c command] [-i|-w|-f] title" >&2
11 echo " -t specifies tty associated with xterm to change" >&2
12 echo " -c specifies command running in this xterm" >&2
13 echo " -i notifies, that only icon name should be changed" >&2
14 echo " -w that window name only (default - both)">&2
15 echo " -f changes font instead of title" >&2
17 # tries to get tty name from command name
18 get_tty_from_command () {
20 echo \"$cmdcolumn\" \"$ttycolumn\"
21 t=`ps $psargs|awk "\\$$cmdcolumn~/$1/ {print \"$ttyprefix\" \\$$ttycolumn;exit}"`
24 echo "None of your processes matches pattern \"$1\"" >&2
29 # checks if supplied tty name is valid device name
33 echo "$i is not valid tty name" >&2
38 echo "$i is not writable for you" >&2
43 # by default change our own xterm title
45 # by default change both window name and icon name
47 set -- `getopt "iwfc:t:h" $*`
51 echo Invalid options. Usage: >&2
61 -t) check_tty $2;shift;shift;;
62 -c) get_tty_from_command $2;shift;shift;;
63 -h) echo "$0: changes a title of xterm window"
71 echo -e "\\033]$mode;$*\a\c" >$tty