<<< Date Index >>>     <<< Thread Index >>>

Re: xterm title (What should go into 1.5.7?)



* On 2005.01.28, in <20050128125026.GJ13946@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
*       "Thomas Roessler" <roessler@xxxxxxxxxxxxxxxxxx> wrote:
> 
> 2. Write a simple shell script that echos the necessary sequences,
> so I could say something like
> 
>         something -title ...
>       something -icon ...
> 
> and get the appropriate sequences echoed (or nothing if this is on

I've had this function in my shell rc for ages. Feel free to take.
The ESC and BEL codes are just to keep it in printable ASCII, because
someone will always cut and paste.

This should be bourne-clean. I don't know whether the TERM list is
complete, but I assume it isn't since nobody makes terminal emulators
anymore, just new terminal types.

# Xterm-compatible terminals can name the title bar.
ESC=`echo @ | tr @ '\033'`
BEL=`echo @ | tr @ '\007'`
name_window_viscera () {
        case "$TERM" in
                dtterm|screen*|xterm*|vt??|vt???) echo "${ESC}]0;$@${BEL}" ;;
        esac
}

name_window () {
        if [ "$1" = - ] ; then
                read wintitle
        else
                wintitle="$@"
        fi
        name_window_viscera "$wintitle"
}