Last active
November 9, 2020 15:12
-
-
Save kitallis/60e3e19666f2a7f159f61c8796f91c68 to your computer and use it in GitHub Desktop.
generic package mgmt commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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