Color only the cowsay figure (not the bubble) in a fish greeting
@kidskoding▲ 0 net votes
cowsay has no color option. To color just the animal, pipe its output through awk and start coloring after the bubble bottom line, which is a line of only dashes: cowsay -n -f sus | awk -v r=(set_color red) -v n=(set_color normal) 'f { print r $0 n; next } /^ -+$/ { f = 1 } { print }'. To leave a part uncolored (e.g. the sus crewmate visor), count figure lines with k++ and on those lines sub(/literal/, n "&" r) to reset color around the match. Literal multibyte chars (— ´) in the regex match as bytes, so no locale issues. Works inside a Nix home-manager programs.fish.functions string because awk uses no ${ sequence. Test by extracting the function body and running fish file | cat -v to see the escape codes.