Skip to content

Instantly share code, notes, and snippets.

@kitallis
Last active November 9, 2020 15:12
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 kitallis/60e3e19666f2a7f159f61c8796f91c68 to your computer and use it in GitHub Desktop.
Save kitallis/60e3e19666f2a7f159f61c8796f91c68 to your computer and use it in GitHub Desktop.
generic package mgmt commands
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage: pakg <i(nstall)|r(emove)|s(earch)|u(pdate)|l(ist)>"
else
os=$([[ -f /etc/os-release ]] && grep ^ID= /etc/os-release | cut -d = -f 2 || uname)
echo --------------------- "$os" --------------------
command=$1
shift
case $os in
debian|Ubuntu)
case $command in
i)
sudo apt-get install "$@"
;;
r)
sudo apt-get remove "$@"
;;
s)
apt-cache search "$@"
;;
u)
sudo apt-get update && sudo apt-get upgrade
;;
l)
sudo apt list --installed
;;
c)
sudo apt-get autoremove
;;
esac
;;
darwin*|Darwin*)
case $command in
i)
brew install "$@"
;;
r)
brew remove "$@"
;;
s)
brew search "$@"
;;
u)
brew update
;;
l)
brew list
;;
c)
brew cleanup
;;
esac
;;
*)
echo "Unknown OS. Please add it to $(basename "$0") pakg function"
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment