0

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 ?

2

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" sequence starts; \e]0; as the set-title command; \u@\h \w as the PS1 expansions for user@host and working directory; \e\\ as the terminator (you'll sometimes see \a used instead); and \] to end the "invisible" region.)

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.