首页 > 解决方案 > 如何在 WSL 中显示当前分支(我使用 Vscode)

问题描述

我使用 Vscode,我想知道我的 HEAD 指向的分支在哪里,
如何显示当前的分支名称,如 Bash?
我在我的 Vscode 中使用 WSL(ubuntu)termimal,操作系统是 Windows 10

谢谢

WSL 图像

标签: bashgitvisual-studio-codewindows-subsystem-for-linux

解决方案


请注意,从microsoft/vscodeissue 67670 开始,当前分支名称已经在 VSCode 的状态栏中可见。

分支VSCode

或者,使用 Git 2.22+(2019 年第二季度)

git branch --show-current

确实,VSCode 中的 git bash 中的提示不显示 Git 分支

您需要配置$SHELL

例如,要启用将 bash 作为登录 shell(运行.bash_profile)运行,请传入-l参数(带双引号):

// Linux
"terminal.integrated.shellArgs.linux": ["-l"]

然后在你~/.bashrc可以包括一个特殊的提示


推荐阅读