What is wrong
The following command was not working for me:
echo -ne "\e]0;MYTITLE\a"
It turns out that my default Cygwin installation includes the following prompt definition in .bashrc:
PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$
Note that the first part of the prompt (\e]0;\w\a
) is setting the windows title every time the prompt appears.
The solution
Add these lines in your .bashrc
that define 2 functions:
function settitle() {
export PS1="\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$ "
echo -ne "\e]0;$1\a"
}
function settitlepath() {
export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$ "
}
Then you can set a custom title with this command:
settitle "MYWonderfullTest here"
or you can revert to cygwin's default (the current path) with this command:
settitlepath
Hope this helps
$PS1
) already contains a control sequence that sets the window title to user@machine:working_directory.-T <title>
in the Windows shortcut properties. Also see themintty man page
.