Search code examples
cygwin

Automatic window title update


Is there a mechanism that could set the title of the cgywin window based on the current value of an environment variable?

I found this small script sometime ago (on SO I think) that allows the window title to be set to a specific string:

echo -ne "\e]2;$@\a\e]1;$@\a";

Background: I have just switched from using Subversion to Perforce (company policy) and find myself repeatedly checking the value of the P4CLIENT environment variable to know what my current workspace is. It would be quite useful to have the title of the cygwin window to automatically contain the current value of that environment variable.


Solution

  • At least if you're using Bash and Mintty, you could check out this post on SuperUser.

    So in your case, you could do something like (single quotes changed to double quotes from the original answer since single quotes don't interpolate):

    echo -ne "\e]0;$P4CLIENT\a"
    

    You could then add that line into your .bashrc file to make it permanent.