我启动了一个git-bash窗口,并输入以下命令:
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为什么git不更新自己的窗口标题而远程bash更新呢?
发布于 2021-11-25 15:47:21
Bash和终端都不会自动更新标题-它必须通过输出必要的控制序列来更新,或者作为PS1的一部分(同时显示提示符),或者通过PROMPT_COMMAND更新。有些发行版已经有一个自定义的shell提示符来更新终端标题,但有些没有。
设置终端标题的控制序列通常是\e]0;NEW TEXT\e\\。(可能会有变化。)例如,要将终端标题设置为user@host /path (即\u@\h \w),可以使用:
PS1+='\[\e]0;\u@\h \w\e\\\]'这是\[,告诉Bash一个“看不见的”(0-宽度)序列开始;\e]0;作为"set标题“终端命令的开始;\u@\h \w作为用户@主机和工作目录的Bash PS1扩展;\e\\作为终止符(\a也是可以接受的,尽管不是标准的);\]结束”不可见“区域。
这应该在您的~/.bashrc中设置,接近其他提示符自定义。
https://unix.stackexchange.com/questions/679037
复制相似问题