Repeat last command with “sudo”

后端 未结 5 946
情歌与酒
情歌与酒 2021-02-01 11:58

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

5条回答
  •  执笔经年
    2021-02-01 12:37

    Use alias redo='sudo $(history -p !!)'. This is the only thing that I have found that works with aliases. The other answers do not work in aliases for some reason, having tried them myself, even though they do work when directly running them.

提交回复
热议问题