#!/bin/sh BUILD_CMD="$1" _do_build() { $BUILD_CMD && { echo -e "\033[32;1;4mSuccess\033[0m" } || { echo -e "\033[31;1;4mFailure\033[0m" } } _do_build inotifywait -m -e close_write,moved_to --include '.*go$' --format %e/%f . | \ while IFS=/ read -r events file; do echo "file $file modified, rebuilding" _do_build done