I have to disagree that this code “does remove files safely” and “makes reasonable defaults about the handling of dependencies”.
function remove --wraps "pacman -Runs"
sudo pacman -Runs --noconfirm $argv
if command_failed
sudo pacman -Rcns $argv &&
if not command_failed
echo "You can always rollback to a previous state of your system, simply by selecting 'Garuda Snapshots' in the boot menu."
end
end
end
Using --noconfirm
while recursively removing packages is insane, and pacman -Rcns
is one of the most aggressive removal commands possible. The fact that you have it print out a reassuring message says it all (“you can always restore a snapshot after this command soft-bricks your computer” ).
If you actually want to make it safe and newbie-friendly, leave the dependencies out of it: pacman -R
, and if that fails pacman -Rc
. If you want to remove orphans afterward, you can use the non-recursive cleanup function from the other thread.
In my opinion that would be much safer, especially since you have it set up so the user cannot control what is happening.