Created
June 20, 2017 19:50
-
-
Save James-Firth/302b533e8479909cf871b42292d1edda to your computer and use it in GitHub Desktop.
Practice safe-sudo'ing with ssudo. Removes elevated priveleges after a command is run to avoid those accidental shutdowns.
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
# Throw this in your .zshrc (.bashrc may work too) | |
safe_sudo() { | |
cmd="${@: 1}" | |
if [ "" = "$cmd" ]; then | |
echo "Missing parameters!"; | |
return 1 | |
fi | |
sudo ${@: 1}; | |
sudo -k; | |
echo "Sudo permissions removed from this terminal." | |
} | |
alias ssudo=safe_sudo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment