I've seen various posts about launching gnome-terminal with multiple tabs and the script below is working for me. That is to say, this script will launch gnome-terminal with various working directories or profiles. . .
#!/bin/sh
gnome-terminal \
--tab --working-directory=$HOME/notes \
--tab --working-directory=$HOME/puppet \
--tab --profile=root-beamish \
--tab --profile=odyssey \
--tab --profile=root
… but I'd like to set a unique title for each tab.
In the case where a tab has its own profile I can change the title from within gnome-terminal with Edit | Profiles | (NAME) | Edit | Title and Command
and then change "Initial Title" to what I want and "When terminal commands set their own titles" from "Replace initial title" to "Keep initial title". However, I'd rather not create a unique profile for every tab. I'd like a generic solution.
I've tried adding --title='MyTitle'
but it doesn't seem to help. I'm using GNOME 2.28.2 on CentOS 6.
Best Answer
Use the
-t
option. (seegnome-terminal --help-terminal-options
)-------- updated at 2011-11-15 22:00:00 --------
So... that worked for me on Solaris 11 Express, with gnome-terminal 2.30.2.
Since then, I've been able to test it on Ubuntu 11.04 (Natty), which uses 2.32.1, and found exactly the same behavior as you.
In the case of Ubuntu, I was able to track it to the ubuntu
.bashrc
file. In particular, the section that looks like:In this case, the PS1 variable is being expanded for terminal types matching
xterm*
andrxvt*
.specifically the part between
PS1="\[\e]0;
and\a\]
. Those get turned into the window title.Once I commented out that whole
case
statement, the behavior of gnome-terminal with the-t
option worked as expected. I'll see if I can find a CentOS 6 box to test this with, too.-------- updated at 2017-11-1 09:38:00 --------
So it looks like more recent versions of Gnome-Terminal have made away with some useful features, like the simple
-t
option to set terminal titles.It is still possible to set terminal titles at runtime, it's just ugly as hell now. You can use
printf
orecho
in the command to effect a title.For example:
To start a terminal window with 1 tab, titled 'My Fancy Title' using
printf
:To start a terminal window with 2 tabs, one running top, and one with a title, using
echo
:This does at least offer an option for setting the terminal title at runtime.
See this post for an option to put a simple function in your
~/.bashrc
to allow for setting and resetting the title at will.