7

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.

Ian Shirley
  • 103
  • 1
  • 1
  • 8

4 Answers4

9

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.

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

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.

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.

Sam
  • 902
  • 12
  • 19
  • 1
    Thank you! An alias with '--color' did it for me. ```alias ls='ls --color' # list with color``` – emveeoh Dec 11 '18 at 15:04
3

Solve Windows vscode Open Git Bash No Color

  1. Download Ansicon

  2. After unzipping, rename this folder to ANSICON and move it to C:\ Program Files \.

  3. Modify the VSCode settings:

     // old config:
     {
         ...
    
         "terminal.integrated.shell.windows": "C:\\Program Files\\ANSICON\\x64\\ansicon.exe",
         "terminal.integrated.shellArgs.windows": [
             "C:\\Program Files\\Git\\bin\\sh.exe",
             "--login",
             "-i"
         ]
     }
    
     // new config with after 2021/05:
    
     {
         ...
    
         "terminal.integrated.defaultProfile.windows": "Git Bash",
         "terminal.integrated.profiles.windows": {
             "Git Bash": {
                 "path": "C:\\Program Files\\ANSICON\\x64\\ansicon.exe",
                 "args": ["C:\\Program Files\\Git\\bin\\bash.exe", "--login", "-i"]
             }
         },
     }
    
  4. Reopen the terminal.

Lucas Yang
  • 31
  • 2
  • This worked for me, but now I cannot scroll up the console output anymore. Is there a way around this? – btonasse Aug 22 '21 at 09:53
1

VSCode team have removed customizing colors from user settings page. Currently using the themes is the only way to customize terminal colors in VSCode. For more information check out issue #6766.

Answer copied from : Color theme for VS Code integrated terminal

Snackdex
  • 674
  • 8
  • 18
0

For MacOS, fire Terminal App, then :

nano .zshrc 

#Add these lines

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

Command W, Y to save file

Dylan B
  • 796
  • 8
  • 16