#!/bin/sh # Run a command, and watch for changes in its output. dir="$HOME/.watch-command" mkdir -p "$dir" hash="`printf '%s' "$@" | md5sum | awk '{print substr($1, 1, 8)}'`" ref="$dir/command-$hash.ref" new="$dir/command-$hash.new" "$@" >"$new" 2>&1 touch "$ref" if diff -u "$ref" "$new" ; then rm -f "$new" else printf '\nTo accept changes:\nmv %s %s\n' "$new" "$ref" fi