I often forget to run commands with sudo. I'm looking for a way to make a bash function (or alias) for repeating the last command with sudo. Something like:
sudo
S() { sudo $(history 1) }
Any ideas?
You can write:
sudo !!
(See §9.3 "History Expansion" in the Bash Reference Manual.)