Is there a way to set the gnome-terminal title from within the terminal itself without having to right click on the tab. Something like:
active-terminal --title "Foo"
There was a related question previously with an answer that almost lets you do this: How to change Gnome-Terminal title? but that doesn't set the gnome-terminal tab title only the window title.
The following will set the terminal's title to "New terminal title":
You will probably also have to change the environment variable PS1, first though, otherwise your changes won't show up because it will reset the title after each command. The default .bashrc that ships with Ubuntu contains the following line:
... the "\e]0;" code tells it to write everything up to the "\a" in both the title and icon-name properties. You need to remove that and set it to something like this (i.e. without the \e]0; code):
Then any changes that you make with the above echo command will change the terminal title. If you're going to use this a lot, you can throw it into a function in your ~/.bashrc file:
Then you can just set the title to "kittens" from the command line by doing:
(You have to restart bash though after editing .bashrc, for your changes to take effect)
Function declarations don't work in all shells, so another approach is to declare an alias like so:
This command in particular causes the title to change to whatever the pwd is.
Of course you will want to initialize the title when you start the terminal, so don't forget to include gnome-terminal --title.
I use a perl script to helps me determine all the argument values first and then it invokes a new terminal like so:
But how you want to initialize those values is up to you...
Your welcome to take the following code and tweak it for your own personal use if you want:
In Ubuntu 12.10 ( I am not sure about previous versions) there is the following line in default .bashrc:
Therefore, to have the title in the form you want, you have just to edit the value of
PS1
at this part. If you want, for example, to have the title as the name of the current directory just change\u@\h:
to\w
to\W