Skip to content

Instantly share code, notes, and snippets.

@D1360-64RC14
Last active June 8, 2023 16:58
Show Gist options
  • Save D1360-64RC14/f927e274e9867c6d22a3facd526c87d7 to your computer and use it in GitHub Desktop.
Save D1360-64RC14/f927e274e9867c6d22a3facd526c87d7 to your computer and use it in GitHub Desktop.
Run last command as sudo. Place the code in .bashrc
function sudoas {
local LAST_COMMAND=$(history 2 | head -n 1 | sed -E 's/ [[:digit:]]+ //')
echo "> sudo $LAST_COMMAND"
sudo $LAST_COMMAND
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment