Q:

Ubuntu: How to I add string to terminal window title from command line?

I am working on a Ubuntu VM where i have multiple terminal windows open at the same time. I switch between them many times and it's hard to keep track of which window has which purpose. So what I want to do is to issue some sort of command from the command line that would permanently alter the title of the window. One approach is to modify the following line in .bashrc to, say, add the word FOO to the title:
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@${InstName}:FOO:\w\a\]$PS1"

Then I would do source .bashrc. The problem is that I only have one .bashrc and many windows. So if I open two windows one after another without changing the line in .bashrc, I'll have FOO in both of them. So I want to issue a command from each window instead. How do I do that? 
NOTE: The stuff around FOO in the PS1 line above is important too, so what I want is to essentially add a window-specific string to the generic PS1 specification above.

A:

Use $$ to get the PID:
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@${InstName}:PID$$:\w\a\]$PS1"

Edit
you can define a variable mytitle 
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@${InstName}:$mytitle:\w\a\]$PS1"

and spawn new terminals with new title
export mytitle=WINDOW1 && gnome-terminal
export mytitle=WINDOW2 && gnome-terminal

