added reflector shortcut to help refresh pacman mirrorlist

This commit is contained in:
Bryan Joshua Pedini 2025-01-28 12:50:43 +01:00
parent af686fe6c0
commit 73f7e37670
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,7 @@ A `pacman` helper script, because you forget all the stupid flags
- remove - remove
- purge - purge
- clean - clean
- reflector
- config - config
`config` is the only flag that is not appended to `pacman` (or `yay`), instead it resolves to `nano /etc/pacman.conf`. `config` is the only flag that is not appended to `pacman` (or `yay`), instead it resolves to `nano /etc/pacman.conf`.

11
pman.sh
View File

@ -36,6 +36,15 @@ elif [ "$command_args" = "config" ]; then
command="nano" command="nano"
command_args="/etc/pacman.conf" command_args="/etc/pacman.conf"
su_needed=true su_needed=true
elif [ "$command_args" = "reflector" ]; then
command="reflector"
command_args=$(cat /etc/pacman.d/mirrorlist 2>/dev/null | grep -e "With.*reflector" | sed 's/#.*reflector //')
# Check if reflector was actually used to generate the mirrorlist
if [ "$command_args" = "" ]; then
echo "Error: reflector was not used to generate mirrorlist or mirrorlist location differ from standard"
exit 1
fi
su_needed=true
fi fi
# If command is empty, command is pacman # If command is empty, command is pacman
@ -144,6 +153,8 @@ case "$command_args" in
echo " remove - pacman -Rs | remove packages & dependencies" echo " remove - pacman -Rs | remove packages & dependencies"
echo " purge - pacman -Rns | remove packages, dependencies & conf" echo " purge - pacman -Rns | remove packages, dependencies & conf"
echo " clean - pacman -Scc | remove all package files & trash" echo " clean - pacman -Scc | remove all package files & trash"
echo " reflector - mirrorlist | refresh the mirrorlist with reflector (if used)"
echo " (do not use if file location differ from default /etc/pacman.d/mirrorlist)"
echo " config - /etc/pacman.conf | edits pacman configuration" echo " config - /etc/pacman.conf | edits pacman configuration"
exit 1 exit 1
fi fi