Created
January 12, 2010 03:59
-
-
Save erithmetic/274886 to your computer and use it in GitHub Desktop.
Command to run the last command as a sudo command
This file contains hidden or 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
#!/bin/bash | |
# | |
# Wish you had just run the last command as sudo? sudoh will do it! | |
# | |
# INSTALLATION | |
# | |
# On Mac OS X, add the following to your ~/.bash_profile: | |
# shopt -s histappend | |
# export PROMPT_COMMAND='history -a' | |
# export HISTIGNORE="sudoh" | |
# | |
# Then run: | |
# curl http://gist.github.com/raw/274886/cbdf5148a2b4aec69e08884599252195942e6680/sudoh -O | |
# sudo mv sudoh /usr/local/bin/sudoh | |
# sudo chmod +x /usr/local/bin/sudoh | |
hist_item=`tail -n 1 ~/.bash_history` | |
echo "SUDO $hist_item" | |
echo $hist_item | xargs sudo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment