Skip to content

Instantly share code, notes, and snippets.

@mikesmullin
Created June 21, 2014 21:18
Show Gist options
  • Save mikesmullin/b6e91e2102163e8486bc to your computer and use it in GitHub Desktop.
Save mikesmullin/b6e91e2102163e8486bc to your computer and use it in GitHub Desktop.
Bash Process Loop
#!/bin/bash
# Process Loop
# Author: Mike Smullin <mike@smullindesign.com>
# License: MIT
# Usage:
#
# ./loop node --debug app.js
#
# Ctrl+C Restarts
# Ctrl+\ Quits
#
ctrl_c() {
echo -en "\n\n*** Restarting ***\n\n"
}
ctrl_backslash() {
echo -en "\n\n*** Killing ***\n\n"
exit 0
}
# trap keyboard interrupt (control-c)
trap ctrl_c SIGINT
trap ctrl_backslash SIGQUIT
# the loop
reset; while true; do $*; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment