If you just want to highlight hidden files (and folders) and you don't care about the coloring of all the other files, then the obvious approach is to run ls -la | grep -E "^| \.[^/|'.].*"
If you want to maintain the other colors, then things start to get tricky, because $LS_COLORS
does not natively support colorizing hidden files as it seems.
I came up with the idea to dynamically append the current directory's hidden files to the $LS_COLORS
environment variable as a pseudo extension, then execute ls -la
and after that run dircolors
to reset the original color schema. Obviously there will be a conflict if a hidden file has the same name as a known extension. Also this method does not work with hidden folders.
Warning: This solution is a (not very thoroughly tested) hack. Use it at your own risk.
for h in $(ls -A | grep "^\."); do LS_COLORS="$LS_COLORS*$h=04;05:"; done; ls -la; eval $(dircolors)
LS_COLORS
. I couldn't figure out how to get it to work for dotfiles but you might want to check it out. – terdon Sep 23 '14 at 14:52*.hide
for example. This answer addresses a similar problem for directories, though the answers to this and the directory problem are probably not the same. – mikeserv Sep 23 '14 at 15:43