@@ -362,6 +362,10 @@ get_uptime() {
362362}
363363
364364get_pkgs () {
365+ # This is just a simple wrapper around 'command -v' to avoid
366+ # spamming '>/dev/null' throughout this function.
367+ has () { command -v " $1 " > /dev/null; }
368+
365369 # This works by first checking for which package managers are
366370 # installed and finally by printing each package manager's
367371 # package list with each package one per line.
@@ -382,39 +386,39 @@ get_pkgs() {
382386 case $os in
383387 Linux* )
384388 # Commands which print packages one per line.
385- command -v kiss && kiss l
386- command -v bonsai && bonsai list
387- command -v pacman-key && pacman -Qq
388- command -v dpkg && dpkg-query -f ' .\n' -W
389- command -v rpm && rpm -qa
390- command -v xbps-query && xbps-query -l
391- command -v apk && apk info
389+ has kiss && kiss l
390+ has bonsai && bonsai list
391+ has pacman-key && pacman -Qq
392+ has dpkg && dpkg-query -f ' .\n' -W
393+ has rpm && rpm -qa
394+ has xbps-query && xbps-query -l
395+ has apk && apk info
392396
393397 # Directories containing packages.
394- command -v brew && printf ' %s\n' " $( brew --cellar) /" *
395- command -v emerge && printf ' %s\n' /var/db/pkg/* /* /
396- command -v pkgtool && printf ' %s\n' /var/log/packages/*
398+ has brew && printf ' %s\n' " $( brew --cellar) /" *
399+ has emerge && printf ' %s\n' /var/db/pkg/* /* /
400+ has pkgtool && printf ' %s\n' /var/log/packages/*
397401
398402 # GUIX requires two commands.
399- command -v guix && {
403+ has guix && {
400404 guix package -p /run/current-system/profile -I
401405 guix package -I
402406 }
403407
404408 # NIX requires two commands.
405- command -v nix-store && {
409+ has nix-store && {
406410 nix-store -q --requisites /run/current-system/sw
407411 nix-store -q --requisites ~ .nix-profile
408412 }
409413 ;;
410414
411415 Darwin* )
412416 # Commands which print packages one per line.
413- command -v pkgin && pkgin list
414- command -v port && port installed
417+ has pkgin && pkgin list
418+ has port && port installed
415419
416420 # Directories containing packages.
417- command -v brew && printf ' %s\n' /usr/local/Cellar/*
421+ has brew && printf ' %s\n' /usr/local/Cellar/*
418422 ;;
419423
420424 FreeBSD* )
0 commit comments