Code Snippets: Sudo Your Last Command [NSFW]

Hey Guys and Gals,
Here’s a little snippet I find handy whenever I’m working on the command line, forget to sudo, and feel like an idiot. Throw this badboy in your .bashrc (or .profile for you mac nerds):

# i'm an idiot
alias fuck='sudo $(history -p \!\!)'

And that’s it! Now when you forget to sudo with a complicated command, you can just type ‘fuck’ and throw in your password. Don’t forget to source your .bashrc once you’re done. I can’t take original credit for this, but I’ve used it for so long, I’m not sure where I originally came across it. If you happen to know, throw it in the comments below!

Later Skaters,

Leave a Reply

Your email address will not be published. Required fields are marked *