Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get terminal title? (or otherwise restore old one)

Tags:

terminal

xterm

Setting terminal title is easy with echo -e "\e]0;some title\007". Works with pretty much every terminal program.

What I want is to set terminal title when some program starts - and restore old one when it finishes. Is this possible?

like image 218
taw Avatar asked Jul 12 '10 22:07

taw


1 Answers

On xterm, the terminal control sequences 22 and 23 work fine, as in

#!/bin/sh
/bin/echo -ne '\033[22;0t'  # Save title on stack
/bin/echo -ne "\033]0;$(date)\007"
sleep 1
/bin/echo -ne '\033[23;0t'  # Restore title from stack

It looks like this isn't supported in the Mac OS X Terminal.App though.

like image 139
phihag Avatar answered Nov 12 '22 22:11

phihag