Setting colors for ls in git bash on windows
Asked Answered
C

4

35

I have installed GitHub for Windows recently and am using the git bash prompt - the one thing that is bugging me right now is when I type LS all directories are listed in blue.

How do I change my git bash shell so that when I type LS the directories are listed in a different color to blue?

Crossover answered 27/12, 2012 at 5:40 Comment(0)
C
57

This is not specifically a git issue but more the shell that you are using. On MINGW32 using Git 2.9+:

  1. C:\Program Files\Git\etc\bash.bashrc
# Uncomment to use the terminal colours set in DIR_COLORS        
eval "$(dircolors -b /etc/DIR_COLORS)"
  1. C:\Program Files\Git\etc\DIR_COLORS

DIR 01;37 # Attribute=bold; Text color=white

DIR_COLORS File:

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00    # no color code at all
#FILE 00      # regular file: use no color at all 
RESET 0       # reset to "normal" color 
DIR 01;37     # directory 
LINK 01;36    # symbolic link.  (If you set this to 'target' instead of a
              # numerical value, the color is as for the file pointed to.)

Also see the following posts:

For older version of Git, the bash_profile in Git_Installation\etc folder got the colors to change:

LS_COLORS='di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'
export LS_COLORS
alias ls='ls -F --color --show-control-chars'
Crossover answered 15/1, 2013 at 7:17 Comment(0)
B
8

Check if you have the file: %USERPROFILE%\.minttyrc
In that file you can configure the RGB values for console colors.
I use the following to have colors easy to read in a dark background:

BoldBlack=128,128,128
Red=255,64,40
BoldRed=255,128,64
Green=64,200,64
BoldGreen=64,255,64
Yellow=190,190,0
BoldYellow=255,255,64
Blue=0,128,255
BoldBlue=128,160,255
Magenta=200,64,255
BoldMagenta=255,128,255
Cyan=64,190,190
BoldCyan=128,255,255
White=200,200,200
BoldWhite=255,255,255
Berlauda answered 16/5, 2017 at 20:44 Comment(2)
Thanks man, I was confused between xterm and mintty. Also, to add, there is a tool to make this scheme: ciembor.github.io/4bit/#Reprography
This is not what the OP asked but it did help meSubjoin
M
3

I was able to modify DIR_COLORS under /c/Program\ Files/Git/etc just by adding ;47 to line 49:

was

DIR 01;34

and now is

DIR 01;34;47

So now the directories are listed with a white background and much easier to read.

Monique answered 31/7, 2017 at 16:0 Comment(0)
H
0

I've never tried to use GIT on Windows ... but you should be able to adjust text colors with "git-config":

There is also a (hidden?) .gitconfig file you should be able to edit directly:

Finally, this link has some good tips:

Haul answered 27/12, 2012 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.