Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know how to load a specific terminal profile as well as loading a config file that the terminal reads, but every time I try to set the title and save the config file, it still returns to the default. I can only change the window title for that session and only with in the menus. If I try something like

gnome-terminal --title="MyTerminal" this brings up a terminal, but the title is still at its default.

So, how do I change the title from the command line and within a config file.

share|improve this question
add comment

4 Answers 4

I just answered a very similar question here: http://askubuntu.com/questions/30988/how-do-you-set-the-title-of-the-active-gnome-terminal-from-the-command-line/31004#31004

Basically, you can set the title in your ~/.bashrc file, but you need to change PS1 environment variable so it doesn't override you by automatically setting the title/icon-name itself. Take a look at the instructions I posted there, and if you can't figure it out from there, or run into any problems, let me know and I'll walk you through it.

share|improve this answer
1  
Actually, I don't want to change all the terminal titles, just one launcher. Still that other discussions looks useful and I will look into it sometime. Thanks. –  user5881 Mar 19 '11 at 21:50
add comment

Looking over the way gome-terminal works, it looks like you need to do a couple things:

  1. Create a new profile, go into Edit -> Current Profile -> Title and Command
  2. Select the option to Keep/Prepend/Append the shell-supplied title (to suit)
  3. Run the command gnome-terminal --title="Wheeee" --profile="The New Profile"

It appears as though the config-file saving is really for session saving (i.e. it stores all your open windows), and it does not save any command-line provided titles, so you can get what you want via a command-line + profile, but not via the config file.

I've taken the liberty of reporting the lack of command-line option saving in the save-config switch against G-T at https://bugzilla.gnome.org/show_bug.cgi?id=645207

share|improve this answer
2  
Actually using the --title="title" does not really work. It does, but immediately changes back. I had to actually go into edit profile and under title select "Keep Initial Title". Thanks for the info. –  user5881 Mar 19 '11 at 21:47
add comment

This is a script I wrote a LONG time ago, still in use today, to modify your *n*x title bars on the fly. I still have not figured out how to change profiles on the fly. Maybe this will help though. this script shoud be titled wlabel to work best. See examples


#!/usr/bin/perl
## Copyright (c) 1995, Tim McCoy, Santa Barbara, CA 93111
## Free use and distribution is granted.  Please retain Credits & history
## hplabel (Original name. So named because it was originally created
## for hpterm windows; later modified for sun and linux)
## V 1.0 simple perl script to change an hpterm, xterm, or openlook title
## and icon name to the current directory or as offered on command line.
## V 1.1 Add dtterm, same as xterm (Thanks to Bill Bennett HP-USA)
## V 1.2 renamed to wlabel for Company/personal use.
## V 1.3 Added environmental variable THISWINDOWLABEL detect to retain
##       a window variable regardless of movement 5/1/2000 TAM
## V 1.4 Finally got around to testing openlook; it doesn't work. Commented
## V 1.5 Fix for openbook supplied by Bill Wagner (ecad.rsc.raytheon.com)
## V 1.6 Cool one line addition to permit/use backticks in THISWINDOWLABEL syntax
&usage if ("@ARGV" =~ /\-[(h|H)]+/);

# print "@ARGV\n";
use Cwd;
my $cwd = &cwd();
$text = (@ARGV) ? "@ARGV" : ($ENV{THISWINDOWLABEL}) ? $ENV{THISWINDOWLABEL} : $cwd ; 
$text =~ s/\n//g; # avoid chomp by converting '\n' to nil (why ??)
$text = `/bin/echo "$text"` if ($text =~ /\`/);  # cool one line change
chomp $text;
exit if (! $text);
## print STDERR "text='$text' cwd='$cwd'\n";
$term = $ENV{"TERM"};                           # determine term type
if ($term =~ /^(xterm|dtterm)$/i)
  {
  printf "%c]2;%s%c", 27, $text, 7;             # modify the window name
  printf "%c]1;%s%c", 27, $text, 7;             # modify the icon name
  }
elsif ($term eq "hpterm")
  {
  $len = length($text);                         # determine length
  printf "%c&f0k%dD%s", 27, $len, $text;        # modify the window name
  printf "%c&f-1k%dD%s", 27, $len, $text;       # modify the icon name
  }
elsif ($term =~/^(openlook|sun-cmd)$/i)
  {
  printf "%c]l%s%c\\", 27, "$text", 27 ;        # modify the window name
  printf "%c]L%s%c\\", 27, "$text", 27;         # modify the icon name
  }

## This script doesn't need anything else but I use the following alias
## to automatically generate my location to the current window.
## alias cd 'cd \!* ; wlabel'

sub usage
  {
  print '
  Simple little script to put the current working directory in
  the window banner and icon titles.  Replaces the useless
  "Terminal" or "Xterm" text to useful information.  When used
  with a cd alias, it performs this function automatically.

  usage: wlabel [{string}]

  Without arguments wlabel generates the current working directory
  name into the banner/icon.  When followed by a plain text string 
  the string is placed in the banner/icon name.  Additionally, if
  the environmental variable THISWINDOWLABEL is set to a value then
  THAT variables contents will be used for the label.  V1.6 adds
  permitting backticks in the THISWINDOWLABEL string. (i.e.; 
  setenv THISWINDOWLABEL '."'`hostname`:`pwd` `date +\"%T\"`'".'
  will yield something like: "myhost:/net/myhome/dir 08:40:07"

  examples:

  % wlabel
  # banner/icon is "/your/current/working/directory"
  % wlabel verilog
  # banner/icon is "verilog"
  % setenv THISWINDOWLABEL "common window"
  # banner/icon still says "verilog"
  % wlabel
  # banner/icon is "common window"

  bugs:

  Telnet windows to other machines will NOT update the banners.
  In fact if the cd alias (described below) is used during a telnet
  session it may generate errors if the wlabel utility is not in the path.
  ( If so then just "unalias cd" )

  alias:

  put this alias in your .cshrc file to automate wlabel:
  % alias cd "cd \!* ; ~/bin/wlabel";

  And, if the icon text does NOT expand to the full label name when
  the cursor passes over it, try adding this to your .Xdefaults file:
  Dtfile*desktopIcon:     large
  I think this is the one I set to make it work right.  (TAM 7/3/01)
  ';
  exit 0;
}
share|improve this answer
    
Very nice! Thanks! –  stephenmm Jan 23 at 17:23
add comment

I was looking for the same and ended up with an obvious solution when I tried (luckily). The case is that you have saved your session in a config file. Then you start it with gnome-terminal --load-config=mysetup.txt

The config file is in an obvious form, with each tab on a different "paragraph" title with something like this : [Terminal0x24db600] You search for the tab that you want to change and add a simple : Title=my tab name

That's all folks !! This way you control everything, either in window level or per tab. You can arrange different profiles for any tab and adapt the result in here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.