Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

MinTTY is the new default Console for Cygwin.

What's a shell command (something I can put in .bashrc, or even better, in .zshrc) to change the title of the MinTTY window ?

I'd like the title of the window to be the path to the current directory, and to have it updated as I switch directories inside the console.

share|improve this question
Cygwin's default prompt setting (i.e. $PS1) already contains a control sequence that sets the window title to user@machine:working_directory. –  ak2 Nov 29 '11 at 8:50

8 Answers 8

You can change it with the xterm control sequence for this, like so:

echo -ne '\e]0;Title\a'

Refer to:

share|improve this answer
Has no effect for me :/ Maybe this trick has broken in the last 6 months? –  voltrevo Mar 5 '13 at 23:36
Are you using bash? –  James Fu Mar 28 '13 at 7:40
It has no effect when issued from within a screen. –  Ярослав Рахматуллин May 3 '13 at 6:29
Probably the problem is that the command prompt is already configured to update the title (for exmaple with the current path), so the command works but it is suddenly overridden by the prompt. –  Andrea Polci Jul 28 '14 at 7:47

In bash, the variable PROMPT_COMMAND can be set to hold a number of commands, seperated by semicolons. you can use that to do the same title setting as described in the other response that talks about zsh.

share|improve this answer
1) echo $PS1 and copy that string to your clipboard or text editor, as in
   echo $PS1
2) edit ~/.bash_profile and add shell code below, replacing $PS1 as necessary but keep the ${TERMINAL_TITLE} variable in the "false" condition.
3) Save the file and set the TERMINAL_TILE environment variable, as in
   export TERMINAL_TITLE="My Custom Title"
4) Source your bash profile, as in
   . ~/.bash_profile

if [ -z "${TERMINAL_TITLE}" ]
  PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
  PS1='\[\e]0;${TERMINAL_TITLE}\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
share|improve this answer

I used Leonel's answer, but I found the title would only flicker when doing this, which means at least the echo command works as intended. I ran zsh interactively with debug mode enabled using

zsh -xv

Changing the directory evidently invokes another function called title() after precmd() and chpwd(), effectively overriding them. So I plugged this into my .zshrc and it worked.

function settitle() {
    echo -ne "\033]2;"$1"\007"
function title() {
    settitle $(cygpath -m `pwd`)

If you prefer to use chpwd() or precmd() instead, simply disable the title function: title(){}.

share|improve this answer

After reading some answers to this question, I was unable to quickly understand why my terminal title stay unchanged.

The following command line is no sufficient

echo -ne "\e]0;MYTITLE\a"

You will need to check that other environment variables doesn't include this kind of directive. For example, with a default Cygwin installation, you could have the following prompt definition:

PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n$

As you can see the first part of the prompt is defining the windows title:


What I've done to change this behavior is to keep by default the original PS1 value, and provide a way to set a custom title. You could add the following in you .bashrc:

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$ "

This way, you could retrieve the path in the windows title :


or set a custom string :

settitle "MYWonderfullTest here"

Hope this helps

share|improve this answer

Place this in .zshrc:

# Change title of MinTTY to current dir
function settitle() {
    echo -ne "\033]2;"$1"\007"
function chpwd() {
    settitle $(cygpath -m `pwd`)

The sequence of special characters in function settitle makes MinTTY change the title of the window.

In zsh, if you define a function with the special name chpwd, it will be invoked after each chdir.

Works on WinXP, with Cygwin 1.7 and MinTTY running zsh.

share|improve this answer

Just wanted to share my solution to this as I use mintty to execute a script.

My mintty shortcut is setup as:

C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico /usr/bin/bash.exe -l -c /scripts/

The script that I wrote which is called in the shortcut above will prompt me for the server I want to connect to AND execute the settitle function defined in the script.


echo "Enter servername when prompted"
echo -n "servername: " 
read servername
function settitle() {
    echo -ne "\033]2;"$servername"\007"
function title() {
    settitle $(cygpath -m `pwd`)
ssh my_username@$servername
share|improve this answer
Why do you define the function title if you do not use it? –  pabouk Nov 12 '13 at 0:18

try add this into .bash_profile

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD/#$HOME/~}\007"'

It works for me.

share|improve this answer
The question is about changing the window title, not a command prompt. –  kenorb Jul 28 at 10:08
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  DavidPostill Jul 28 at 10:50
please add this into .bash_profile, it is OK for change title, thanks! –  netawater Jul 28 at 14:28

Your Answer


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.