xpm

x package manager, a uniform interface to various POSIX package managers
git clone git://src.gearsix.net/xpm
Log | Files | Refs | Atom | README

commit 988c7ae5c3855db9a594c2b6b628c2fadb3b7627
parent a9f84d5d80a1dc2e07f263593e69c384a133650d
Author: gearsix <gearsix@tuta.io>
Date:   Thu, 17 Mar 2022 16:57:10 +0000

set_xpm_* -> xpm_*, now perform function

Diffstat:
Mxpm.sh | 60++++++++++++++++++++++++++++++------------------------------
1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/xpm.sh b/xpm.sh @@ -3,8 +3,7 @@ xpm="" INSTALLED=~/.local/share/xpm/installed.txt -# track installed -track_installed_add() { +installed_add() { if [ ! -d $(dirname $INSTALLED) ]; then mkdir -p $(dirname $INSTALLED) fi @@ -12,55 +11,60 @@ track_installed_add() { for pkg in $@; do if [ "$(grep $pkg $INSTALLED)" = "" ]; then echo $pkg >> "$INSTALLED" - else - echo "grep" - grep $pkg $INSTALLED fi done } -track_installed_rm() { +installed_rm() { for pkg in $@; do if [ "$(grep $pkg $INSTALLED)" != "" ]; then sed -i "/$pkg/d" "$INSTALLED" - else - echo "grep" - grep $pkg $INSTALLED fi done } -# x package manager unknown_pm() { echo "unknown package manager" exit } xpm_install() { - if [ $(command -v apt) ]; then xpm="sudo apt install" - elif [ $(command -v zypper) ]; then xpm="sudo zypper install" - elif [ $(command -v xbps-install) ]; then xpm="sudo xbps-install -Rs" + if [ $(command -v apt) ]; then + sudo apt install $@ + elif [ $(command -v zypper) ]; then + sudo zypper install $@ + elif [ $(command -v xbps-install) ]; then + sudo xbps-install -Rs $@ else unknown_pm; fi } xpm_remove() { - if [ $(command -v apt) ]; then xpm="sudo apt remove" - elif [ $(command -v zypper) ]; then xpm="sudo zypper remove" - elif [ $(command -v xbps-remove) ]; then xpm="sudo xbps-remove -R" + if [ $(command -v apt) ]; then + sudo apt remove $@ && sudo apt autoremove -y + elif [ $(command -v zypper) ]; then + sudo zypper remove -u $@ + elif [ $(command -v xbps-remove) ]; then + sudo xbps-remove -R $@ else unknown_pm; fi } xpm_search() { - if [ $(command -v apt) ]; then xpm="apt search" - elif [ $(command -v zypper) ]; then xpm="zypper search" - elif [ $(command -v xbps-query) ]; then xpm="xbps-query -Rs" + if [ $(command -v apt) ]; then + apt search $@ + elif [ $(command -v zypper) ]; then + zypper search $@ + elif [ $(command -v xbps-query) ]; then + xbps-query -Rs $@ else unknown_pm; fi } xpm_query() { - if [ $(command -v apt) ]; then xpm="apt list --installed" - elif [ $(command -v zypper) ]; then xpm="zypper search --installed-only" - elif [ $(command -v xbps-query) ]; then xpm="xbps-query -S" + if [ $(command -v apt) ]; then + apt list --installed $@ + elif [ $(command -v zypper) ]; then + zypper search --installed-only $@ + elif [ $(command -v xbps-query) ]; then + xbps-query -S $@ else unknown_pm; fi } @@ -68,22 +72,18 @@ xpm_query() { case "$1" in "i"|"in"|"install") shift - xpm_install - $xpm $@ && track_installed_add $@ + xpm_install $@ && installed_add $@ ;; "r"|"rm"|"remove") shift - xpm_remove - $xpm $@ && track_installed_rm $@ + xpm_remove $@ && installed_rm $@ ;; "s"|"se"|"search") shift - xpm_search - $xpm $@ + xpm_search $@ ;; "q"|"qry"|"query") shift - xpm_query - $xpm $@ + xpm_query $@ ;; esac