tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: colorls in base



As a service to the community, I hereby present my colorls script:

/bin/ls -al $@ | awk '
function p(s, color) { printf("%c[0;%dm%s%c[0m\n", 27, color, s, 27); }
BEGIN { black = 30; red = 31; green = 32; yellow = 33; blue = 34; purple =
35; cyan = 36 ; gray = 37 }
/^d........t/ { p($0, green); next }
/^d........T/ { p($0, yellow); next }
/^dr/ { p($0, cyan); next }
/^-r..r.s/ { p($0, purple); next }
/^l/ { p($0, green); next }
/^-r.x/ { p($0, red); next }
/^-r.s/ { p($0, yellow); next }
{ print }
'

and (for free!) my colordf script:

/bin/df -h $@ | awk '
function p(s, color) { printf("%c[0;%dm%s%c[0m\n", 27, color, s, 27); }
BEGIN { black = 30; red = 31; green = 32; yellow = 33; blue = 34; purple =
35; cyan = 36 ; gray = 37 }
$1 == "Filesystem" { print; next }
{ if (match($0, "[0-9]+%") > 0) { num = substr($0, RSTART, RLENGTH - 1) +
0; c = green; if (num >= 95) { c = red } else if (num >= 90) c = yellow; }
p($0, c) }
'

and I further propose that they don't go anywhere near base :)

(my motivation is that my eyes are not getting any better, and i need the
visual cues that coloring gives me. If anyone doubts it would work for
them, I'd like to ask you how your mono tv is doing, and ask why the
warning lights on your car are so bright?)


Home | Main Index | Thread Index | Old Index