ConEmu与Git Bash-在选项卡栏中显示文件夹 [英] ConEmu with Git Bash - Show folder in tab bar
问题描述
我通常在ConEmu选项卡中运行Git Bash.在每个Git Bash实例的选项卡栏中显示当前目录的名称确实非常方便,但是如果我将选项卡模板设置为%d
或%f
,无论如何我总会得到Windows主目录我在Git Bash中cd
的位置.
I'm usually running Git Bash in ConEmu tabs. It would be really handy to show the name of the current directory in the tab bar for each instance of Git Bash, but if I set the tab template to %d
or %f
, I always get my Windows home directory, no matter where I cd
to in Git Bash.
是否可以在标签栏中显示路径?从所附的屏幕截图中可以看到,我已导航到banana
文件夹,但是ccook
(我的主目录)显示在选项卡中.
Is there a way to display the path in the tab bar? As you can see from the attached screenshot, I'm navigated to the banana
folder, but ccook
(my home dir) is shown in the tab.
标题(%s
)似乎包含完整路径,但是对于我的选项卡来说太长了.
The Title (%s
) seems to contain the full path, but that's too long for my tabs.
我目前能达到的最好的效果是使用%s
并将MINGW64
作为标题中的跳过单词添加,但这仍然为我提供了完整的路径,而不仅仅是我的当前文件夹.如果可以指定正则表达式,我可以排除最后一个/
之后的文字,但不包括其他任何内容.
The best I'm currently able to achieve is to use %s
and add MINGW64
as a Skipped word from title, but that still gets me the full path instead of just the current folder. If there was a way to specify a regex I could exclude everything but the text after the final /
.
推荐答案
对于Cygwin用户,请将PROMPT_COMMAND='ConEmuC -StoreCWD'
添加到.bashrc.
For Cygwin users, add PROMPT_COMMAND='ConEmuC -StoreCWD'
to the .bashrc.
根据@ Jeffrey-Harmon的建议
Per suggestion from @Jeffrey-Harmon
if [[ -n "${ConEmuPID}" ]]; then
PROMPT_COMMAND='ConEmuC -StoreCWD'
fi
从文档页面看,现在也有此建议.
Looking at the documentation page, this suggestion is there as well now.
https://conemu.github.io/en/ShellWorkDir.html#bash_and_other_cygwin_shells
这篇关于ConEmu与Git Bash-在选项卡栏中显示文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!