VS Code中集成终端中的Bash终端颜色

问题描述 投票:3回答:3

我在Windows 10机器上,我最近安装了VS Code而不是Sublime Text 3.我将VS Code中的集成终端更改为默认为git Bash。现在工作得很好,但我似乎丢失了文件和目录的颜色编码。我尝试将eval "$(dircolors -b /etc/DIR_COLORS)"添加到我的.bash_profile但它仍然无法在集成终端中工作,但是如果我在外部打开Bash,我的所有颜色仍然存在。

terminal visual-studio-code
3个回答
3
投票

通过配置我的C:\Program Files\Git\etc\bash.bashrc文件,我能够在VSCode中的Bash集成终端中使用颜色。我发现仅仅单独使用eval "$(dircolors -b /etc/DIR_COLORS)"是不够的。在我的C:\Program Files\Git\etc\DIR_COLORS文件的顶部,我看到了这个:

# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.

所以我测试使用ls --color它工作!然后我在bash.bashrc中创建了以下别名:

alias ls='ls --color' # list with color
alias la='ls -alF'    # list all

我还发现你可以通过编辑C:\Program Files\Git\etc\profile.d\git-prompt.sh文件并在bash.bashrc中包含shopt -q login_shell || . /etc/profile.d/git-prompt.sh来自定义Bash提示的颜色(和组合)。

我无法解释为什么集成终端需要ls别名,但现在我很高兴,因为我的颜色现在与外部终端匹配。


1
投票

VSCode团队已从用户设置页面中删除了自定义颜色。目前使用主题是在VSCode中自定义终端颜色的唯一方法。有关更多信息,请查看问题#6766

答案复制自:Color theme for VS Code integrated terminal


0
投票

解决Windows vscode Open Git Bash No Color

  1. 下载Ansicon
  2. 解压缩后,将此文件夹重命名为ANSICON并将其移至C:\ Program Files \
  3. 修改VSCode设置: { ... "terminal.integrated.shell.windows": "C:\\Program Files\\ANSICON\\x64\\ansicon.exe", "terminal.integrated.shellArgs.windows": [ "C:\\Program Files\\Git\\bin\\sh.exe", "--login", "-i" ] }
  4. 重新打开终端。
© www.soinside.com 2019 - 2024. All rights reserved.