Skip to content

Commit 137382d

Browse files
committed
fix homebrew package miscount
1 parent 6d17194 commit 137382d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pfetch

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,17 @@ macports_pkg_count() {
711711
port installed 2>/dev/null | grep active
712712
}
713713

714+
homebrew_pkg_count() {
715+
cellar="$(brew --cellar)"
716+
caskroom="$(brew --caskroom)"
717+
if ! [ "$(printf '%s\n' "$cellar"/*)" = "$cellar/*" ]; then
718+
printf '%s\n' "$cellar"/*
719+
fi
720+
if ! [ "$(printf '%s\n' "$caskroom"/*)" = "$caskroom/*" ]; then
721+
printf '%s\n' "$caskroom"/*
722+
fi
723+
}
724+
714725
count_pkg() {
715726
# This function is used to count the number of packages installed
716727
# from each individual package manager.
@@ -805,8 +816,7 @@ get_pkgs() {
805816
# Directories containing packages.
806817
has kiss && count_pkg kiss 0 printf '%s\n' /var/db/kiss/installed/*/
807818
has cpt-list && count_pkg cpt-list 0 printf '%s\n' /var/db/cpt/installed/*/
808-
has brew &&
809-
count_pkg brew 0 printf '%s\n' "$(brew --cellar)/"* "$(brew --caskroom)/"*
819+
has brew && count_pkg brew 0 homebrew_pkg_count
810820
has emerge && count_pkg portage 0 printf '%s\n' /var/db/pkg/*/*/
811821
has pkgtool && count_pkg pkgtool 0 printf '%s\n' /var/log/packages/*
812822
has eopkg && count_pkg eopkg 0 printf '%s\n' /var/lib/eopkg/package/*
@@ -830,7 +840,8 @@ get_pkgs() {
830840

831841
[ -d /var/packages ] && count_pkg dsm 0 printf '%s\n' /var/packages/*
832842

833-
has appimaged && count_pkg appimage 0 printf '%s\n' "$HOME"/.local/bin/*.[Aa]pp[Ii]mage "$HOME"/Applications/*.[Aa]pp[Ii]mage
843+
has appimaged &&
844+
count_pkg appimage 0 printf '%s\n' "$HOME"/.local/bin/*.[Aa]pp[Ii]mage "$HOME"/Applications/*.[Aa]pp[Ii]mage
834845

835846
# Has devbox & is initialized
836847
has devbox &&
@@ -860,8 +871,7 @@ get_pkgs() {
860871
has port && count_pkg macports 0 macports_pkg_count
861872

862873
# Directories containing packages.
863-
has brew &&
864-
count_pkg brew 0 printf '%s\n' "$(brew --cellar)/"* "$(brew --caskroom)/"*
874+
has brew && count_pkg brew 0 homebrew_pkg_count
865875
;;
866876

867877
(FreeBSD*|DragonFly*)

0 commit comments

Comments
 (0)