81

I have a problem with dark-blue color in vim or ls output. Because I'm using black background color, words colored in dark-blue are almost completely invisible. How can I address this problem?

8 Answers8

71

You can modify the color theme of vim with the background option. Use

set background=dark

in your current session or set it permanent in your vimrc.

The output of ls is configured with /etc/DIR_COLORS. See the manpage for more information. The settings can be overwritten with a ~/.dir_colors (On Ubuntu: ~/.dircolors - see entry in ~/.bashrc) file in your home directory.

An entry like

 DIR 01;36 

will produce a more readable background with cyan.

Cookie
  • 414
echox
  • 18,103
  • 2
    For those new to bash: after creating your file (e.g., ~/.dircolors) as directed here, you just have to source ~/.bashrc to see it working. Thanks for this answer! – Marcus Oct 11 '19 at 16:31
36

Rather than configure applications to avoid blue on black, I recommend configuring your terminal to make the blue more visible. Most terminal emulators have a setting for that. In xterm, there's an X resource:

XTerm.VT100.color4: CornflowerBlue

In other terminal emulators, look in the configuration file or dialog for color settings or themes.

There is a common control sequence to set the shade associated with a color number from the application: OSC 4 ; c ; spec BEL where OSC is ESC ], c is the color number and spec is a color spec such as #RGB.

printf %b '\e]4;4;#6495ed\a'  # set the blue shade to CornflowerBlue

A change by the application is only effective until the next terminal reset. If you use this method (only recommended if your terminal lacks a configuration mechanism), to make the change effectively persistent, append the color configuration escape sequence to your terminal's reset string (termcap: r1 string; terminfo: rs1 string).

See also Overriding the shade of color displayed, Can I set my local machine's terminal colors to use those of the machine I ssh into?.

  • Solarized (http://ethanschoonover.com/solarized) has nice color schemes for various terminal emulators and other programs. – David Feb 23 '16 at 16:24
  • if you are using GNOME Terminal, preferences -> Profile -> colours. At the bottom is a checkbox 'show bold text in bright colours' does essentially the same thing. – dan carter May 11 '22 at 07:44
14

A faster way to set the ls directory color for your terminal session:

1. Open your terminal run the dircolors command:

machines@box790 ~ $ dircolors
LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS
machines@box790 ~ $ 

It's parroting you the command for you to set the colors for ls. The 'di' stands for directory. 34 is the bad dark blue. 36 is cyan. So lets paste it, and change it into the terminal.

2. Copy that whole thing into the terminal, making a single change

You change the di=01;34 to di=01;36 like this:

machines@box790 ~ $ LS_COLORS='rs=0:di=01;36:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';

machines@box790 ~ $ export LS_COLORS

3. This sets the directory colors to cyan immediately

do an 'ls' and see that directories are indeed cyan.

4. Make the above step permanent

Make it permanent by placing the above commands at the bottom of your ~/.bashrc like this:

LS_COLORS='rs=0:di=01;36:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS

If you put this into your ~/.bashrc and (restart the terminal or source ~/.bashrc), the colors should still be right.

  • 3
    The color scheme for dircolors can be saved in a human-readable file, and applied from bashrc with eval "dircolors -b ~/.dir_colors". See here colorscheme examples. – alexei Sep 19 '15 at 02:41
  • now my symlink is the same color as dir – ealeon Sep 16 '19 at 17:15
  • @ealeon Ah, it does appear that directories di and symlinks ln have the same color as 01;36. Feel free to switch up those colors, if that particular distinction is important to you. This colorscheme is a default one I found kicking around. – Eric Leschinski Sep 16 '19 at 17:26
8

If you inform vim that you are using a black background (or otherwise dark theme) it will lighten up all the colors so they are readable:

:set bg=dark
Caleb
  • 70,105
4

For me, this work best:

LS_COLORS="$LS_COLORS:di=00;44"

Screenshot of ls -lah with this color

You can make this permanent with:

echo 'LS_COLORS="$LS_COLORS:di=00;44"' >> ~/.bashrc
Walf
  • 1,321
Daniel
  • 41
2

This will load the ls colours for the current shell, replacing blue with cyan.

eval `dircolors | sed -e 's/;34:/;36:/'`

It sets the environment variable LS_COLORS.

joeytwiddle
  • 1,018
  • 9
  • 15
Spongman
  • 232
0

Using xfce4-terminal I struggled with this problem for a long time until it really broke my work.

I found out, that one can change the representation for the different colors in the "Palette" in the "xfce4-terminal"-settings. So that dark-blue would be represented as light-blue or anything else that fits your background-color. See screenshot: enter image description here

MacMartin
  • 2,924
0

Run dircolors, you will see something like di=01;34. Here, 01 means bold. So you just need to change it to 00, which means default color. You could add

eval `dircolors | tr 01 00`

in your .bashrc.

I use MobaXterm and it works for me.

AdminBee
  • 22,803