VS Code 中集成终端中的 Bash 终端颜色 [英] Bash terminal colors in integrated terminal in VS Code
问题描述
我在 Windows 10 机器上,我最近安装了 VS Code 来代替 Sublime Text 3.我将 VS Code 中的集成终端更改为默认为 git Bash.现在工作得很好,但我似乎丢失了文件和目录的颜色编码.我尝试将 eval "$(dircolors -b/etc/DIR_COLORS)"
添加到我的 .bash_profile 但它仍然无法在集成终端中工作,但是如果我在外部打开 Bash,我的所有颜色都是还在.
I'm on a windows 10 machine and I recently installed VS Code to use instead of Sublime Text 3. I changed the integrated terminal in VS Code to default to git Bash. That is working just fine now but I seemed to have lost my color coding for files and directories. I tried adding eval "$(dircolors -b /etc/DIR_COLORS)"
to my .bash_profile but it still doesn't work in the integrated terminal, however if I open Bash externally all of my colors are still there.
推荐答案
通过配置我的 C:\Program Files\Git\etc\bash,我能够在 VSCode 的 Bash 集成终端中使用颜色.bashrc
文件.我发现仅仅使用 eval "$(dircolors -b/etc/DIR_COLORS)"
是不够的.在我的 C:\Program Files\Git\etc\DIR_COLORS
文件的顶部,我看到了这个:
I was able to get colors to work in my Bash integrated terminal in VSCode by configuring my C:\Program Files\Git\etc\bash.bashrc
file. I found that simply using eval "$(dircolors -b /etc/DIR_COLORS)"
alone was not sufficient. At the top of my C:\Program Files\Git\etc\DIR_COLORS
file I saw this:
# 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 中创建了以下别名:
So I tested using ls --color
and it worked! I then created the following aliases in 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 提示的颜色(和组成)并包括 shopt -q login_shell ||.bash.bashrc 中的/etc/profile.d/git-prompt.sh
.
I also found that you can customize the colors (and composition) of the Bash prompt by editing the C:\Program Files\Git\etc\profile.d\git-prompt.sh
file and including shopt -q login_shell || . /etc/profile.d/git-prompt.sh
in bash.bashrc.
我无法解释为什么集成终端需要 ls 别名,但现在我很高兴,因为我的颜色现在与外部终端相匹配.
I can't explain why the ls alias is needed for the integrated terminal but now I'm happy since my colors now match the external terminal.
这篇关于VS Code 中集成终端中的 Bash 终端颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!