Created
March 25, 2016 20:02
-
-
Save dealloc/85584959c9feba37646a to your computer and use it in GitHub Desktop.
prompt sudo once and forget about it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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