Skip to content

Instantly share code, notes, and snippets.

@dealloc
Created March 25, 2016 20:02
Show Gist options
  • Save dealloc/85584959c9feba37646a to your computer and use it in GitHub Desktop.
Save dealloc/85584959c9feba37646a to your computer and use it in GitHub Desktop.
prompt sudo once and forget about it
startsudo()
{
sudo -v
( while true; do sudo -v; sleep 50; done; ) &
SUDO_PID="$!"
trap stopsudo SIGINT SIGTERM
}
stopsudo()
{
kill "$SUDO_PID"
trap - SIGINT SIGTERM
sudo -k
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment