It’s possible to define a few rules outside of simple extension-based ones using LS_COLORS. You can for example match literal filenames with no extension or simple globs:

# matches README as well as *.README etc
*README 38;5;220;1

# matches rtorrent.rc as well as .zshrc etc
*rc     38;5;204

lscolors_literal

A few days ago I started using beets to once and for all organize my music collection. It’s great. While organizing, I wanted to get a quick sense of what my mp3:flac ratio looks like. I like to keep both mp3 and flac versions of albums if possible.

Turns out, simply matching *FLAC* in LS_COLORS doesn’t work. What you can’t do in LS_COLORS, you can however do with ls++:

ls++.conf:

%ls_colors = (
  '(?i)\(FLAC\)' => '204',
  '(?i)\(MP3\)'  => '137',
);

The (?i) tells ls++ to match case insensitive. Here, I’ve chosen color index 204 for FLAC and index 137 for MP3, the same colors that I use to list files with these extensions:

$LS_COLORS:

.flac 38;5;204
.mp3  38;5;137

And it looks like this:

colors

Though the patterns above are very simple, we can use the full power of perl regex to add attributes to whatever we want, or how about matching season premieres:

%ls_colors = (
  '(?i)(s[0-9]{2}-s[0-9]{2}|s([0-9]{1,2})[eEx]01)|([Ss]?([0-9]{1,2}))[Eex]01' => 'bold reverse italic 196',
);

premiere