A recent change introduced in GNU coreutils changed the default dircolors for backup files to make them less conspicuous. However, despite having stated that it works on dark backgrounds, this change made it impossible to see backup files such as .tar
, .swp
, .bak
, .old
when using the dark variant of the Solarized color scheme of the terminal. It can be seen in the following screenshots:
To fix it, we’ll override the colors by creating ~/.dircolors
file:
$ dircolors -p | sed "s/00;90/00;30/g" > ~/.dircolors
$ eval $(dircolors -b ~/.dircolors)
This will set the color of backup files to black, which makes them not stand out, but still readable.
This is the bash
function I used to pretty-print all ls
colors:
( # Run in a subshell so it won't crash current color settings
dircolors -b >/dev/null
IFS=:
for ls_color in ${LS_COLORS[@]}; do # For all colors
color=${ls_color##*=}
ext=${ls_color%%=*}
echo -en "\E[${color}m${ext}\E[0m " # echo color and extension
done
echo
)
Another option, albeit more verbose, would be
$ dircolors --print-ls-colors ~/.dircolors | paste -sd ''