Merge pull request #229 from dylanaraps/pkg_fix
Fix issues with users having more than one package manager installed.
This commit is contained in:
commit
dc579d3fb3
83
neofetch
83
neofetch
|
@ -646,69 +646,58 @@ getuptime () {
|
||||||
getpackages () {
|
getpackages () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux")
|
||||||
if type -p pacman >/dev/null 2>&1; then
|
type -p pacman >/dev/null 2>&1 && \
|
||||||
packages="$(pacman -Qq --color never | wc -l)"
|
packages="$(pacman -Qq --color never | wc -l)"
|
||||||
|
|
||||||
elif type -p dpkg >/dev/null 2>&1; then
|
type -p dpkg >/dev/null 2>&1 && \
|
||||||
packages="$(dpkg --get-selections | grep -cv deinstall$)"
|
packages=$((packages+=$(dpkg --get-selections | grep -cv deinstall$)))
|
||||||
|
|
||||||
elif type -p /sbin/pkgtool >/dev/null 2>&1; then
|
type -p /sbin/pkgtool >/dev/null 2>&1 && \
|
||||||
packages="$(ls -1 /var/log/packages | wc -l)"
|
packages=$((packages+=$(ls -1 /var/log/packages | wc -l)))
|
||||||
|
|
||||||
elif type -p rpm >/dev/null 2>&1; then
|
type -p rpm >/dev/null 2>&1 && \
|
||||||
packages="$(rpm -qa | wc -l)"
|
packages=$((packages+=$(rpm -qa | wc -l)))
|
||||||
|
|
||||||
elif type -p xbps-query >/dev/null 2>&1; then
|
type -p xbps-query >/dev/null 2>&1 && \
|
||||||
packages="$(xbps-query -l | wc -l)"
|
packages=$((packages+=$(xbps-query -l | wc -l)))
|
||||||
|
|
||||||
elif type -p pkginfo >/dev/null 2>&1; then
|
type -p pkginfo >/dev/null 2>&1 && \
|
||||||
packages="$(pkginfo -i | wc -l)"
|
packages=$((packages+=$(pkginfo -i | wc -l)))
|
||||||
|
|
||||||
elif type -p pisi >/dev/null 2>&1; then
|
type -p pisi >/dev/null 2>&1 && \
|
||||||
packages="$(pisi list-installed | wc -l)"
|
packages=$((packages+=$(pisi list-installed | wc -l)))
|
||||||
|
|
||||||
elif type -p pkg >/dev/null 2>&1; then
|
type -p pkg >/dev/null 2>&1 && \
|
||||||
packages="$(ls -1 /var/db/pkg | wc -l)"
|
packages=$((packages+=$(ls -1 /var/db/pkg | wc -l)))
|
||||||
|
|
||||||
elif type -p emerge >/dev/null 2>&1; then
|
type -p emerge >/dev/null 2>&1 && \
|
||||||
packages="$(ls -d /var/db/pkg/*/* | wc -l)"
|
packages=$((packages+=$(ls -d /var/db/pkg/*/* | wc -l)))
|
||||||
|
|
||||||
elif type -p nix-env >/dev/null 2>&1; then
|
type -p nix-env >/dev/null 2>&1 && \
|
||||||
packages="$(ls -d -1 /nix/store/*/ | wc -l)"
|
packages=$((packages+=$(ls -d -1 /nix/store/*/ | wc -l)))
|
||||||
|
|
||||||
elif type -p apk >/dev/null 2>&1; then
|
type -p apk >/dev/null 2>&1 && \
|
||||||
packages="$(apk info | wc -l)"
|
packages=$((packages+=$(apk info | wc -l)))
|
||||||
|
|
||||||
elif type -p pacman-g2 >/dev/null 2>&1; then
|
type -p pacman-g2 >/dev/null 2>&1 && \
|
||||||
packages="$(pacman-g2 -Q | wc -l)"
|
packages=$((packages+=$(pacman-g2 -Q | wc -l)))
|
||||||
|
|
||||||
elif type -p cave >/dev/null 2>&1; then
|
type -p cave >/dev/null 2>&1 && \
|
||||||
cross_packages=$(ls -d -1 /var/db/paludis/repositories/cross-installed/*/data/* | wc -l)
|
packages=$((packages+=$(ls -d -1 /var/db/paludis/repositories/cross-installed/*/data/* /var/db/paludis/repositories/installed/data/* | wc -l)))
|
||||||
packages=$(ls -d -1 /var/db/paludis/repositories/installed/data/* | wc -l)
|
|
||||||
packages=$((packages + cross_packages))
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
if [ -d "/usr/local/bin" ]; then
|
[ -d "/usr/local/bin" ] && \
|
||||||
local_packages=$(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l)
|
packages=$(($(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - 1))
|
||||||
packages=$((local_packages - 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if type -p port >/dev/null 2>&1; then
|
type -p port >/dev/null 2>&1 && \
|
||||||
port_packages=$(port installed 2>/dev/null | wc -l)
|
packages=$((packages + $(port installed 2>/dev/null | wc -l) - 1))
|
||||||
packages=$((packages + port_packages - 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if type -p brew >/dev/null 2>&1; then
|
type -p brew >/dev/null 2>&1 && \
|
||||||
brew_packages=$(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l)
|
packages=$((packages + $(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l) - 1))
|
||||||
packages=$((packages + brew_packages - 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if type -p pkgin >/dev/null 2>&1; then
|
type -p pkgin >/dev/null 2>&1 && \
|
||||||
pkgsrc_packages=$(pkgin list 2>/dev/null | wc -l)
|
packages=$((packages + $(pkgin list 2>/dev/null | wc -l)))
|
||||||
packages=$((packages + pkgsrc_packages))
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*"BSD")
|
*"BSD")
|
||||||
|
@ -724,10 +713,8 @@ getpackages () {
|
||||||
packages=$(cygcheck -cd | wc -l)
|
packages=$(cygcheck -cd | wc -l)
|
||||||
|
|
||||||
# Count chocolatey packages
|
# Count chocolatey packages
|
||||||
if [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]; then
|
[ -d "/cygdrive/c/ProgramData/chocolatey/lib" ] && \
|
||||||
choco_packages=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)
|
packages=$((packages+=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)))
|
||||||
packages=$((packages + choco_packages))
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
packages=${packages// }
|
packages=${packages// }
|
||||||
|
|
Reference in New Issue