Skip to content

Instantly share code, notes, and snippets.

@coltenkrauter
Created September 14, 2023 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coltenkrauter/636c3c25c8023854afb7451a36acddc7 to your computer and use it in GitHub Desktop.
Save coltenkrauter/636c3c25c8023854afb7451a36acddc7 to your computer and use it in GitHub Desktop.
This zsh script surveys your UNIX system to identify which package managers are installed, swiftly scanning through a predefined list of popular managers and signaling their availability, making the task of installing new software packages a breeze.
#!/bin/zsh
# Define a list of package managers to check
package_managers=("apt" "yum" "dnf" "brew" "zypper" "pacman" "emerge" "nix" "snap" "flatpak")
echo "Initiating package manager detection..."
# Start checking phase
echo "\e[32m==> Starting Detection Phase\e[0m"
# Loop through the array of package managers and check if they are installed
for manager in "${package_managers[@]}"; do
if command -v $manager > /dev/null; then
echo "\e[35m→ $manager is installed\e[0m"
else
echo "$manager is not installed"
fi
done
# Ending checking phase
echo "\e[32m==> Ending Detection Phase\e[0m"
# Conclusion report
echo "\e[34m\033[1mConclusion:\033[0m \e[34mAbove listed are the detected package managers on your system.\e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment