public
Last active — forked from ginatrapani/todo.txt final filter

Specially colorizes priority, date and project.

  • Download Gist
todo.txt%20final%20filter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/bin/bash
export COLOR_CONTEXT=$GREEN
export COLOR_PROJECT=$RED
export COLOR_DATE=$LIGHT_GREEN
# Force gawk to behave posixly. Comment out if you get an error about
# no such option -W.
# AWK_OPTIONS="-W posix"
if [ "$TODOTXT_PLAIN" -eq "0" ]; then
awk $AWK_OPTIONS '
function highlight(colorVar, color) {
color = ENVIRON[colorVar]
gsub(/\\+033/, "\033", color)
return color
}
{ color = "DEFAULT" }
/\(A\)/ { color = "PRI_A" }
/\(B\)/ { color = "PRI_B" }
/\(C\)/ { color = "PRI_C" }
/\([D-Z]\)/ { color = "PRI_X" }
{
gsub(/@[^ ]*/, highlight("COLOR_CONTEXT") "&" highlight(color));
gsub(/\+[^ ]*/, highlight("COLOR_PROJECT") "&" highlight(color));
sub(/[0-9]{4}(-[0-9]{2}){2}/, highlight("COLOR_DATE") "&" highlight(color));
print
}
'
else
cat
fi

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.