5

I have a script which does a long build. It takes like hours for this script to complete, and while the build is going on there is no way for me to know how much the script has run. For that I thought of changing the name of the xterm from the script to reflect the subscript.

So, the question is how do I change the xterm title from script ?

I tried adding lines like: echo -e '\033k'$mytitle'\033\' which I got from some other post, but it doesnt work.

Thanks for the help !

singleX
  • 375
  • 4
  • 13

3 Answers3

7

There is a program called xtermcontrol which lets you have full control over xterm stuff like that.

If you cannot set the title, perhaps it is locked:

xterm*allowTitleOps: false

You can normally pull up the Font menu (control-right) and check or uncheck the "Allow Title Ops" button to configure this at runtime. Checked allows you to change the title.

Also this program works for me:

#!/bin/bash
#
#

echo -ne "\033]0;$@\007"

Type carefully!

Seth Robertson
  • 30,608
  • 7
  • 64
  • 57
  • @Manoj: What did it do? How did you run it? If you named this shell script "xtermtitle" and then said `xtermtitle test | md5sum` do you get "02eb32c3f0b0241a6ffab4209b3e2045"? Do you have the Allow Title ops checked? – Seth Robertson Jun 29 '11 at 20:36
  • I have a function in the .bashrc: – singleX Jun 29 '11 at 20:38
  • @Manoj: You didn't do either of the things I asked. Make sure that the character sequence that should update the title to test generates the md5sum I mentioned. Did you check for the Allow Title Ops bit being checked? – Seth Robertson Jun 29 '11 at 20:40
  • Yes, I got that long number on the shell when I run it like that. (but not as title) – singleX Jun 29 '11 at 20:40
  • Sorry, I am new with scripting, How do I check "Allow Title Ops" ? – singleX Jun 29 '11 at 20:41
  • @Manoj: And when you check the Font menu is the "Allow Title Ops" checked? – Seth Robertson Jun 29 '11 at 20:41
  • @Manoj: In the xterm window, hit the control key and then the right mouse button. You should get a menu up saying "VT Fonts". Look near the bottom for "Allow Title Ops". Is there a checkmark next to it? – Seth Robertson Jun 29 '11 at 20:43
  • Hi Seth, there is no "Allow Title Ops". But, there is on "UTF-8 Titles" which was checked. – singleX Jun 29 '11 at 20:47
  • 1
    @Manoj: Hmm. Man page says: `These are disabled if the SendEvents feature is enabled` You could try setting the X resource – Seth Robertson Jun 29 '11 at 21:10
  • 1
    Try running `echo "xterm*allowTitleOps: true" | xrdb -merge` and then start a new xterm. – Seth Robertson Jun 29 '11 at 22:24
  • @SethRobertson Just want to say thanks to you as your comment helped solve my problem. I wasn't aware sendEvents would disable setting title and somehow added that option... – L__ May 27 '13 at 23:22
2

The correct escape for setting xterm title seem to be \033]0; and \007, see http://tldp.org/HOWTO/Xterm-Title-4.html for tips, and http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 for the escape sequence definition.

tonio
  • 10,355
  • 2
  • 46
  • 60
0

Take a loo at this post

Set screen-title from shellscript

As per the post you are missing a \ and it should be

echo -e '\033k'$mytitle'\033\\'
Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • Sorry, that was a typo in typing the question. I was copy pasting the commands. So, I have it exactly same in my script as what is given there. But, doesnt work – singleX Jun 29 '11 at 20:34