1

I started a git-bash window, and type following commands :

git-bash ~$ echo $BASH_VERSION
4.4.23(1)-release
git-bash ~$ type cd
cd is a shell builtin
git-bash ~$ cd tmp
git-bash ~/tmp$
# Change of directory is NOT refelected on git-bash window title

git-bash ~/tmp$ ssh user@linux
[user@linux ~]$ echo $BASH_VERSION
4.4.20(1)-release
[user@linux ~]$ type cd
cd is a shell builtin
[user@linux ~]$ cd tmp
[user@linux ~/tmp]$
# Change of directory   IS   refelected on git-bash window title

Why does git-bash NOT update its own window title whereas a remote bash DOES ?

1 Answer 1

4

Neither Bash nor the terminal will update the title automatically – it has to be updated by outputting the necessary control sequences either as part of PS1 (at the same time when the prompt is shown) or through PROMPT_COMMAND. Some distributions already have a custom shell prompt that updates the terminal title, but some don't.

The control sequence that sets terminal title is usually \e]0;NEW TEXT\e\\. (There may be variations.) For example, to set the terminal title to user@host /path (i.e. \u@\h \w) you could use:

PS1+='\[\e]0;\u@\h \w\e\\\]'

That's \[ to tell Bash an "invisible" (0-width) sequence starts;
\e]0; as the start of "set title" terminal command;
\u@\h \w as the Bash PS1 expansions for user@host and working directory;
\e\\ as the terminator (\a is also acceptable though nonstandard);
and \] to end the "invisible" region.

This should be set in your ~/.bashrc, near the other prompt customizations.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .