entr(1)

Run arbitrary commands when files change

project page

Testing

To test a script run manually, run the awk script and type the status lines using the format exit_or_signal exit_code utility_name

awk -F '|' -f bold.awk
exit|0|bash
signal|15|bash
^D

Examples using -x

Pass/Fail

{
  if ($2 == "0")
    print "✔ pass"
  else
    print "✘ fail"
}

No Status

{ }

Hilight Status

function bold(s) {
  return "\033[1;37m"s"\033[0m"
}
function underline(s) {
  return "\033[4m"s"\033[0m"
}
/^signal/ { print underline($3), "terminated by signal", bold($2); }
/^exit/ { print underline($3), "returned exit code", bold($2); }

Examples using -xx

Change Tmux Status

{
  if ($2 == "0")
    system("tmux set status-style fg=black,bg=green")
  else
    system("tmux set status-style fg=white,bg=red")
}

Compatibility

Distributions that use busybox, such as Alpine Linux do not have a secure/sandbox flag for awk. Use -xx option or install gawk.