Skip to content

Instantly share code, notes, and snippets.

@James-Firth
Created June 20, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save James-Firth/302b533e8479909cf871b42292d1edda to your computer and use it in GitHub Desktop.
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.
# 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