Skip to content

Instantly share code, notes, and snippets.

@ntpeters
Last active November 10, 2017 17:16
Show Gist options
  • Save ntpeters/ca6a3a0cccf075a0bc8c to your computer and use it in GitHub Desktop.
Save ntpeters/ca6a3a0cccf075a0bc8c to your computer and use it in GitHub Desktop.
ZSH Compatible Sudo Bang Bang
# Add to your '.zshrc' file to create an alias to 'sudo !!'
# Elevates the last run command using sudo
function elevate_last_command() {
# Check if running with ZSH history verification
if [ -z ${HIST_VERIFY+x} ]; then
setopt no_histverify
sudo `fc -ln -1`
setopt histverify
else
sudo `fc -ln -1`
fi
}
# Assign an alias to the function
alias please=elevate_last_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment