Skip to content

Instantly share code, notes, and snippets.

@mermshaus
Created August 19, 2016 15:33
Show Gist options
  • Save mermshaus/8d6cba55c2bca629bdeb6d90066c647b to your computer and use it in GitHub Desktop.
Save mermshaus/8d6cba55c2bca629bdeb6d90066c647b to your computer and use it in GitHub Desktop.
#!/bin/bash
# marc-watchphp -- Executes a PHP script file when its content changes.
#
# Usage: $ marc-watchphp <file>
#
# Working directory MUST be file's directory. Press Ctrl-C to stop.
inotifywait -q -m -e close_write,moved_to --format %e/%f . |
while IFS=/ read -r events file; do
if [ "$file" = "$1" ]; then
date=$(date)
echo "+=================================================================="
echo "| $date"
echo "| \$ php -f $file"
echo "+=================================================================="
php -f "$file"
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment