[tpwd] Fix segfault when exactly one argument given
[tinyapps.git] / settitle
blob0268ff1f67b83f4d0977662d8fcca3ac716f3b41
1 #!/bin/sh
2 ##
3 ## Sets the title of xterm-compatible terminals.
4 ## By Stanislaw Klekot (dozzie/AT/irc.pl)
5 ## Released to Public Domain
6 ##
7 ## This is part of Tiny Applications Collection
8 ## -> http://tinyapps.sourceforge.net/
9 ##
11 if [ $# = 0 ]; then
12 title=$TERM
13 else
14 title=$*
17 tput=$(which tpute 2>/dev/null)
18 if [ -n "$tput" ]; then
19 if tput tsl; then
20 printf '%s' "$title"
21 tput fsl
23 else
24 printf '\33]2;%s\7' "$title"