#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: xtitle.osh 410 2008-05-15 05:01:41Z jneitzel $ " : : " 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;' ; \ ps -oppid -p$$ | sed '1d ; 2s,.*,ps -ocommand -p&,' | osh - | \ sed '1d ; 2s,^\([^ ]*\) *.*$,\1,' ; \ printf "%b" ': '$u'@' ; printenv HOST ; \ printf "%b" ' (' ; printenv TTY | cut -d/ -f3 ; printf "%b" ')\007' ; \ ) | tr -d '\n' >/dev/tty