Last active
July 27, 2016 13:26
-
-
Save addiedx44/5638037 to your computer and use it in GitHub Desktop.
Runs the last command with sudo if you curse at your terminal. Add this to your .bashrc.
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
# Runs the last command with sudo if you curse at your terminal. | |
# | |
# $ whoami | |
# adam | |
# $ how about now, motherfucker? | |
# root | |
# | |
debug_trap () { | |
re="(fuck|shit)" | |
if [[ $BASH_COMMAND =~ $re ]]; then | |
sudo bash <<EOF | |
$(history -p !-1) | |
EOF | |
return 1 | |
fi | |
} | |
shopt -s extdebug | |
trap debug_trap DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment