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=5 ;# 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
16 echo " -r raises/deiconifies window instead of changing title" >&2
18 # tries to get tty name from command name
19 get_tty_from_command () {
21 echo \"$cmdcolumn\" \"$ttycolumn\"
22 t=`ps $psargs|awk "\\$$cmdcolumn~/$1/ {print \"$ttyprefix\" \\$$ttycolumn;exit}"`
25 echo "None of your processes matches pattern \"$1\"" >&2
30 # checks if supplied tty name is valid device name
34 echo "$i is not valid tty name" >&2
39 echo "$i is not writable for you" >&2
44 # by default change our own xterm title
46 # by default change both window name and icon name
48 set -- `getopt "iwrfc:t:h" $*`
52 echo Invalid options. Usage: >&2
62 -t) check_tty $2;shift;shift;;
63 -c) get_tty_from_command $2;shift;shift;;
64 -h) echo "$0: changes a title of xterm window"
68 -r) raise_mode=1; shift;;
74 if [ -n "$raise_mode" ]; then
75 echo -ne "\\033[1t\\033[5t" >$tty
77 echo -e "\\033]$mode;$*\a\c" >$tty