#!/usr/bin/env bash # Store the first command line argument in the variable "command" and shift the rest command_args="$1" shift # Evaluate the command arguments if [ "$command_args" = "search" ]; then command="pacman" command_args="-Ss" elif [ "$command_args" = "update" ]; then command="pacman" command_args="-Sy" su_needed=true elif [ "$command_args" = "upgradable" ]; then command="pacman" command_args="-Qu" elif [ "$command_args" = "upgrade" ]; then command="pacman" command_args="-Syu" su_needed=true elif [ "$command_args" = "install" ]; then command="pacman" command_args="-S" su_needed=true elif [ "$command_args" = "provides" ]; then command="pacman" command_args="-F" elif [ "$command_args" = "config" ]; then command="nano" command_args="/etc/pacman.conf" su_needed=true else echo "Invalid command: \"$command_args\"" echo echo "Usage: pman [args...]" echo "Available commands:" echo " search - pacman -Ss | search packages" echo " update - pacman -Sy | updates the repositories" echo " upgradable - pacman -Qu | list available upgrades" echo " upgrade - pacman -Syu | upgrades your system" echo " provides - pacman -F | list packages that provide file" echo " config - /etc/pacman.conf | edits pacman configuration" exit 1 fi # If sudo is needed and necessary (and installed), prepend it if [ "$su_needed" = "true" ] && [ "$UID" != 0 ] && command -v "sudo" &>/dev/null; then sudo $command $command_args "${@}" else $command $command_args "${@}" fi