windowsgitbashgit-bashtitlebar

How to change title of Git terminal in Windows?


I work in Windows 10 and usually I have up to 5 CMD windows open. I work this way because I need to run the same application with different data and keep monitoring if any exception is thrown.

I set a number as the window's title (using the title command) instead of the default text, in order to easily identify which window I'm working in and be able to identify and change between them using Alt+Tab (an example of how I work with my CMD windows)

Recently I started to use Git and I really like the Git Bash terminal for Windows. I would like to work with Git Bash terminal the same way I work with CMD windows, but I can't find any way to change the window title. I searched a bit and found these instructions and some others (that I can't paste because I'm not allowed to post more than two links yet), but it seems to work only by setting a different default title. I'd like to change the window title to any custom text I choose, at any moment.

Is this possible? Is there a command like title available for Git Bash?


Solution

  • Here is a simple way to change the title text to anything you want. create a title.sh script somewhere on your system like in C:\bin that has the following content:

    #!/bin/sh
    export TITLEPREFIX="$*"
    

    Add the following to your .bashrc file in your home directory.

    alias title='. /c/bin/title.sh'
    

    Now open a git bash window. You can now type:

    title my title
    

    and your title will start with the title you provided to the title alias.