If you have to alias these operations, do it like this:
alias install="sudo pacman -S"
#alias update="sudo pacman -Syu" # one y, not two
alias update="yay" # better than above, but alias is stupid (more typing)
alias search="pacman -Ss" # no sudo
alias search-local="pacman -Qs" # no sudo
alias pkg-info="pacman -Qi" # no sudo
alias local-install="sudo pacman -U"
alias clear-cache="sudo pacman -Scc"
alias unlock="sudo rm /var/lib/pacman/db.lck"
alias remove="sudo pacman -R"
alias autoremove="sudo pacman -Rns" # understand what it does before using it
However, I would recommend learning what these commands to rather than memorising a bunch of aliases.
Also, as a personal preference, I never put sudo in aliases. Typing out the word sudo in the terminal is a great time to reflect upon oneās actions: āIs this really what I want? Do I really need to be root to do it?ā
I see your posts are useful. Any posts of anybody I see useful even if proven wrong. One way is learning from mistakes. They say a rational/reasonable man is who learns from āhisā mistakes, and a wise man is who learns from āothersā mistake.
So, I am this āotherā who makes users āwiseā
Thank you.
An interesting clarification. I donāt think a package that is an optional dependency of another package will ever be on the list of orphans. I believe the reason optional dependencies get removed is because of how pacman -Rs works.
I started removing orphans in a pacman -R loop to avoid this behaviour. To be honest, I have always kind of felt it was a bug in pacman but I guess you can look at either way.
That is true. But @Kresimirās other point is still valid.
An orphan is package that was brought in as a dependency of another package that is no longer installed. It has nothing to do with if you want/need that package.
You as the end-user need to review the list of orphans and determine if you want to remove them or not.
Yeah, that cleans the orphan packages, but I still wouldnāt do it like that, but go through the list and decide what to remove, what to leave alone, and what to mark as explicitly installed.
I did a test and found that both commands do not lead to the same result. pacman deletes e.g. no packages where one of the packages to be deleted is listed as āDepends Onā or 'Required By '. yay -Yc deletes those too.