From 22e888ed483fd9f52be3e00827995e8b8ba702f3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 26 Apr 2016 17:31:13 +1000 Subject: [PATCH] Reduce size of package manager function --- neofetch | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/neofetch b/neofetch index 056b997d..6c28aefd 100755 --- a/neofetch +++ b/neofetch @@ -687,25 +687,17 @@ getpackages () { ;; "Mac OS X") - if [ -d "/usr/local/bin" ]; then - local_packages=$(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - packages=$((local_packages - 1)) - fi + [ -d "/usr/local/bin" ] && \ + packages=$(($(ls -l /usr/local/bin/ | grep -v "\(../Cellar/\|brew\)" | wc -l) - 1)) - if type -p port >/dev/null 2>&1; then - port_packages=$(port installed 2>/dev/null | wc -l) - packages=$((packages + port_packages - 1)) - fi + type -p port >/dev/null 2>&1 && \ + packages=$((packages + $(port installed 2>/dev/null | wc -l) - 1)) - if type -p brew >/dev/null 2>&1; then - brew_packages=$(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l) - packages=$((packages + brew_packages - 1)) - fi + type -p brew >/dev/null 2>&1 && \ + packages=$((packages + $(find /usr/local/Cellar -maxdepth 1 2>/dev/null | wc -l) - 1)) - if type -p pkgin >/dev/null 2>&1; then - pkgsrc_packages=$(pkgin list 2>/dev/null | wc -l) - packages=$((packages + pkgsrc_packages)) - fi + type -p pkgin >/dev/null 2>&1 && \ + packages=$((packages + $(pkgin list 2>/dev/null | wc -l))) ;; *"BSD") @@ -721,10 +713,8 @@ getpackages () { packages=$(cygcheck -cd | wc -l) # Count chocolatey packages - if [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]; then - choco_packages=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l) - packages=$((packages + choco_packages)) - fi + [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ] && \ + packages=$((packages+=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l))) ;; esac packages=${packages// }