5 Commits

2 changed files with 57 additions and 20 deletions

View File

@@ -1,15 +1,24 @@
# pman.sh # pman.sh
A `pacman` helper script, because you forget the stupid flags A `pacman` helper script, because you forget all the stupid flags
## Usage / Features: ## Usage / Features:
- aur/yay
- search - search
- info
- localinfo
- provides
- providefiles
- installed
- install
- update - update
- upgradable - upgradable
- upgrade - upgrade
- install - remove
- provides - purge
- clean
- reflector
- config - config
`config` is the only flag that is not appended to `pacman`, 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`.
`sudo` gets prepended automatically if the command requires it and if installed - no, there is no check if your user is in the `sudo` group, if you download this script you should already be, or know you can only use part of this utility `sudo` gets prepended automatically if the command requires it and if installed - no, there is no check if your user is in the `sudo` group, if you download this script you should already be, or know you can only use part of this utility

60
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
@@ -64,6 +73,15 @@ case "$command_args" in
su_needed=false su_needed=false
command_args="-F" command_args="-F"
;; ;;
"providefiles")
# Update the cache
su_needed=true
command_args="-Fy"
execute_command "${@}"
su_needed=false
command_args="-Fl"
;;
"installed") "installed")
command_args="-Q" command_args="-Q"
;; ;;
@@ -78,6 +96,13 @@ case "$command_args" in
if [ "$command" = "pacman" ]; then if [ "$command" = "pacman" ]; then
su_needed=true su_needed=true
fi fi
execute_command "${@}"
su_needed=false
command_args="-Qu"
echo
echo "$(execute_command "${@}" | wc -l) packages are available for update"
exit 0
;; ;;
"upgradable") "upgradable")
command_args="-Qu" command_args="-Qu"
@@ -108,26 +133,29 @@ case "$command_args" in
;; ;;
*) *)
if [ "$more_arguments" = "true" ]; then if [ "$more_arguments" = "true" ]; then
echo "Invalid command: \"$command $command_args\"" echo "Invalid command: \"$command_args\""
echo echo
echo "Usage: pman <command> [args...]" echo "Usage: pman <command> [args...]"
echo "Available commands:" echo "Available commands:"
echo " yay (aur) - yay | invoke yay " echo " yay (aur) - yay | invoke yay "
echo " (aur packages - all the normal operations except config are available)" echo " (aur packages - all the normal operations except config are available)"
echo " aur (yay) - yay | same as \"yay\"" echo " aur (yay) - yay | same as \"yay\""
echo " search - pacman -Ss | search packages" echo " search - pacman -Ss | search packages"
echo " info - pacman -Si | show package information" echo " info - pacman -Si | show package information"
echo " localinfo - pacman -Qi | show local package information" echo " localinfo - pacman -Qi | show local package information"
echo " provides - pacman -F | list packages that provide file" echo " provides - pacman -F | list packages that provide file"
echo " installed - pacman -Q | list installed packages" echo " providefiles - pacman -Fl | list files provided by package"
echo " install - pacman -S | install packages" echo " installed - pacman -Q | list installed packages"
echo " update - pacman -Sy | updates the repositories" echo " install - pacman -S | install packages"
echo " upgradable - pacman -Qu | list available upgrades" echo " update - pacman -Sy | updates the repositories"
echo " upgrade - pacman -Syu | upgrades your system" echo " upgradable - pacman -Qu | list available upgrades"
echo " remove - pacman -Rs | remove packages & dependencies" echo " upgrade - pacman -Syu | upgrades your system"
echo " purge - pacman -Rns | remove packages, dependencies & conf" echo " remove - pacman -Rs | remove packages & dependencies"
echo " clean - pacman -Scc | remove all package files & trash" echo " purge - pacman -Rns | remove packages, dependencies & conf"
echo " config - /etc/pacman.conf | edits pacman configuration" 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"
exit 1 exit 1
fi fi
;; ;;