From 59340ff4cecafad33c44603e09b72483e0970e13 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 28 Sep 2019 07:25:20 +0300 Subject: [PATCH] pkgs: fix extra count --- pfetch | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pfetch b/pfetch index 20fcb81..dd7f6e0 100755 --- a/pfetch +++ b/pfetch @@ -362,6 +362,10 @@ get_uptime() { } get_pkgs() { + # This is just a simple wrapper around 'command -v' to avoid + # spamming '>/dev/null' throughout this function. + has() { command -v "$1" >/dev/null; } + # This works by first checking for which package managers are # installed and finally by printing each package manager's # package list with each package one per line. @@ -382,27 +386,27 @@ get_pkgs() { case $os in Linux*) # Commands which print packages one per line. - command -v kiss && kiss l - command -v bonsai && bonsai list - command -v pacman-key && pacman -Qq - command -v dpkg && dpkg-query -f '.\n' -W - command -v rpm && rpm -qa - command -v xbps-query && xbps-query -l - command -v apk && apk info + has kiss && kiss l + has bonsai && bonsai list + has pacman-key && pacman -Qq + has dpkg && dpkg-query -f '.\n' -W + has rpm && rpm -qa + has xbps-query && xbps-query -l + has apk && apk info # Directories containing packages. - command -v brew && printf '%s\n' "$(brew --cellar)/"* - command -v emerge && printf '%s\n' /var/db/pkg/*/*/ - command -v pkgtool && printf '%s\n' /var/log/packages/* + has brew && printf '%s\n' "$(brew --cellar)/"* + has emerge && printf '%s\n' /var/db/pkg/*/*/ + has pkgtool && printf '%s\n' /var/log/packages/* # GUIX requires two commands. - command -v guix && { + has guix && { guix package -p /run/current-system/profile -I guix package -I } # NIX requires two commands. - command -v nix-store && { + has nix-store && { nix-store -q --requisites /run/current-system/sw nix-store -q --requisites ~.nix-profile } @@ -410,11 +414,11 @@ get_pkgs() { Darwin*) # Commands which print packages one per line. - command -v pkgin && pkgin list - command -v port && port installed + has pkgin && pkgin list + has port && port installed # Directories containing packages. - command -v brew && printf '%s\n' /usr/local/Cellar/* + has brew && printf '%s\n' /usr/local/Cellar/* ;; FreeBSD*)