Post History
TL;DR When pacman bugs you for sudo, in bash or zsh (and possibly others but I haven't verified that), run sudo !! Full Answer As I see it you have 2 options: command substitution or an alias (o...
Answer
#1: Initial revision
# TL;DR When pacman bugs you for sudo, in bash or zsh (and possibly others but I haven't verified that), run `sudo !!` # Full Answer As I see it you have 2 options: command substitution or an alias (or new command entirely). Neither are a perfect solution but can help lessen the disruption to your flow. ## Command History Substitution This doesn't stop pacman from requiring sudo, nor will it stop it from bugging you, but it will make rerunning it with sudo much easier. If you just ran `pacman -Syu` or some similar command that requires sudo and it nags you, you can run `sudo !!` and it will autocomplete to `sudo <whatever command you just executed>`. For more info, see the relevant sections of the [bash manual](https://www.gnu.org/software/bash/manual/bash.html#Event-Designators) and [zsh manual](https://zsh.sourceforge.io/Doc/Release/Expansion.html#History-Expansion). (If anyone can verify that this works, or knows of a similar solution, for other shells, post a comment or edit this answer.) ## Make an Alias or New Command You can define an alias in `~/.bashrc` (or `~/.bash_aliases` if there's a reference to it in .bashrc,) to whichever `pacman` command you want to use. For example: - `alias pacs='sudo pacman -S'` or `alias pacmans='sudo pacman -S'` - `alias pacr='sudo pacman -R'` or `alias pacmanr='sudo pacman -R'` - `alias pacu='sudo pacman -U'` or `alias pacmanu='sudo pacman -U'` This would require you to get muscle memory going to use these commands instead of `pacman -S`, etc., and it's not something that would carry over from one system to the next, but it would stop pacman from nagging you about sudo. This could, in theory, also conflict with other potential commands that might have the same name (though I don't know of any that would, off the top of my head). Making a new command is almost exactly the same, except instead of defining it in .bashrc, you would make a new file somewhere in your path (i.e. any of the directories listed when you execute `echo $PATH`) and enter the text in the example aliases after the `=` (minus the `'`s) there.