#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 2cfc3701ecc9133bb1d9ad32a11f1e4bee6a6fff $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " Set the window title for terminal emulators under X. " : : " usage: xtitle [string] " : : " Check for correct usage. " : >>$0'' <'' ; : >>$1'' <'' killer $0 xtitle if $n != 0 -a $n != 1 if { exit } pusage $0 '"[string]"' ( : " Fail if this process does not have a controlling terminal. " ) >/dev/tty : : " Exit quietly w/ a non-zero status if the value of TERM does not match " : " the following pattern. Change the pattern according to your needs. " : printenv TERM | egrep '^(rxvt|rxvt-unicode|xterm|xterm-color)$' >/dev/null if $s != 0 if { exit } false : : " If $1 is specified, set the window title to the specified value. " : if $n = 1 if { exit } printf "%b" '\033]0;'$1'\007' >/dev/tty : : " Otherwise, set it to a nice default value... " : ( \ printf "%b" '\033]0;' ; echo $$ | \ sed 's,^0*\(.*\),ps -oppid -p\1,' | osh - | \ sed -n '2s,.*,ps -oargs -p&,p' | osh - | \ sed -n '2s,^\([^ ]*\) *.*,\1,p' ; \ printf "%b" ': '$u'@' ; printenv HOST ; \ printf "%b" ' (' ; printenv TTY | cut -d/ -f3- ; printf "%b" ')\007' ; \ ) | tr -d '\n' >/dev/tty