LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-13-2007, 03:04 AM   #1
hroit
Member
 
Registered: May 2006
Posts: 31

Rep: Reputation: 15
Can you dynamically set the title of new tabs in gnome terminal?


It's really handy to have tabs in gnome terminal, and I often use several. Often, however, I lose track of who's who.

Unlike, say, a browser, gnome-terminal keeps the same default title on all tabs. Yet, under the Title and Command tab (edit - current profile), it says:
Quote:
The command running inside a terminal may dynamically set a new title
an option which I enable.

According to
Code:
man gnome-terminal
it is possible to use
Code:
gnome-terminal -t <my_title>
to get a new window with the desired title.

This indeed works fine.

Now, I'd like to be able to set the title of a new tab.
While a new tab can be opened either from the menus or from the keyboard, commands seem to only open new windows. So, I can not use the -t flag to set the title of a new tab...

Is there a way of doing this which escapes me?

Thanks.

jackn
 
Old 08-13-2007, 05:21 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
First, maybe clicking or double-clicking or right-clicking on tab caption will allow you to set its caption after it is open. Also I have a script
Code:
\echo -e "\x1B]2;$1\x07";
(when script is run, its argument is substituted instead of $1). It changes window caption for xterm and tab captions in tabbed terminals I tried it on. Try this script. (It outputs an escape sequence which is interpreted by whatever draws the console. Text console driver ignores it and X11 terminal emulators change session caption).
 
Old 08-13-2007, 05:56 PM   #3
hroit
Member
 
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 15
I've tried the command raskin provided. I wasn't able to get it to work. Maybe I don't know how to. I provided an argument both after the semicolon and with the semicolon removed. I also tried to remove the leading slash.

As to the answer, I've made some progress.

A simple way is to use the menus: Terminal - set title (which can be done without leaving the keyboard: Alt-t, s).

As to the command line, Mariano Suárez-Alvarez, one of the two authors of gnome-terminal kindly provided the following answer:
Quote:
You can use the xterm control sequences to set the window title:
ESC ] 2 ; your_title BEL

For example,

echo -e '\033]2;Hello\007'

will make 'Hello' to be your title (the 2 means 'set both the window
title and the icon title; other values are 0 and 1 which only affect
one of them)
I only understand this very paritally - an xterm control sequence is provided first in principle, and then a concrete example, which solves the current problem.
I've tried it and it works very well.

The command line, as opposed to the menus, has the advantage of allowing the setting up of a simple alias.

raskin's script is similar to Mariano's command.

The -e flag in the 'echo' command allows 'echo' to understand escape backslashes.

Thank you for your help, raskin.

Sorry about the double post, acid kewpie. I wasn't trying to get attention, I thought I was an editing, not reposting.

jackn
 
Old 08-14-2007, 02:58 AM   #4
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
Really my command should do exactly the same as Alvarez's ... It just uses another notation for nonprintables (and backslash crept in my script and was left unnoticed because it does not change behavior). Try
Code:
echo -e '\033]2;Hello\007' | hexdump
and post output.
 
Old 08-14-2007, 11:51 AM   #5
hroit
Member
 
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 15
Here you go, raskin:

Code:
~$ echo -e '\033]2;Hello\007' | hexdump
0000000 5d1b 3b32 6548 6c6c 076f 000a          
000000b
 
Old 08-14-2007, 11:59 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
Try running the same command ( echo -e '\033]2;Hello\007' ) in xterm. Will its caption change? If exactly the same command changes xterm's caption, but doesn't affect gnome-terminal, I would suspect bug in gnome-terminal (possibly introduced by distribution).
 
Old 08-15-2007, 02:43 AM   #7
hroit
Member
 
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 15
The command you had me run works both in xterm and in gnome-terminal.

I'm not sure what the purpose of this experiment was, as it's the command that I used to begin with, and that worked, in gnome-terminal.

Could you enlighten me a bit on what's going here with the xterm control sequences and hexdump, or where I could find out more about that?

I have no idea what's going on it wouldn't hurt to learn a thing or two.

jackn
 
Old 08-15-2007, 02:47 AM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
Sorry, then I just misunderstood you. From your post I thought you had some problem (now I see that I misread it), and fell into standard escape-code debugging procedure. Sorry once again...
 
Old 08-15-2007, 11:49 PM   #9
hroit
Member
 
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks for your help and attention, raskin.

jackn
 
Old 08-23-2007, 03:22 PM   #10
hroit
Member
 
Registered: May 2006
Posts: 31

Original Poster
Rep: Reputation: 15
Just to complete this thread with what I've learned since, which might come in handy.

Obviously, there are menu options for this, accessible with the mouse: Terminal - Set Title.
More interestingly, like other menu items, this is accessible from the keyboard: Alt+t for the 'Terminal' menu, then 's' for 'Set title'.

Nicer yet, as the help manual says, the 'grave' (as in the French accent, also known as the 'backtick') key, directly gives rise to the 'Set title' dialogue box.

Nicest of all, key bindings for all such menu items can be easily set. Once the menu is dropped down and the item is highlighted, any key combination (other than the one activating the item) entered will become a shortcut.
The shortcut just entered will figure to the right of the menu item, as shortcuts usually do.
Changed your mind? Just type in another one. Finally want none? Hit backspace, and the shortcut is blank.

jackn
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get the title of xterm/gnome-terminal redleafong Linux - Software 6 01-10-2011 06:38 PM
manipulating gnome-terminal title, post-creation dengel Linux - Desktop 2 02-28-2007 09:43 AM
Using tabs with Eterm similar to Gnome terminal O(V)eGA_l2el) Fedora 0 11-21-2006 08:37 AM
gnome-terminal how-to set lines/rows? longtex Linux - Software 3 10-21-2005 03:06 PM
How to set the window title for Eterm dynamically? MiscGeek Linux - Software 4 09-29-2003 09:33 PM


All times are GMT -5. The time now is 02:06 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration