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

Ian*_*ley 5 terminal visual-studio-code

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

Sam*_*Sam 9

通过配置我的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.
Run Code Online (Sandbox Code Playgroud)

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

alias ls='ls --color' # list with color
alias la='ls -alF'    # list all
Run Code Online (Sandbox Code Playgroud)

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

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