Checksumcolor

var ansi = frequire("Term::ANSIColor")

func colorhash(hash) {
    hash.split(2).map{|s| ansi.colored(s, "ansi" + s.hex) }.join
}

ARGF.each {|line|
    if (STDOUT.is_on_tty && (line =~ /^([[:xdigit:]]+)(.*)/)) {|m|
        say (colorhash(m[0]), m[1])
    }
    else {
        say line
    }
}

% md5sum \*.sf | sf checksumcolor.sf f8ac04c1857c109145e1bf0fe25550d2 checksumcolor (copy).sf f8ac04c1857c109145e1bf0fe25550d2 checksumcolor.sf af086941b6dc67001cd831bb1f22c3ed farey.sf b585c25146e94df370ec48466911d9ae pell.sf

Last updated