From a721d2d4559d81d62ac5a295b2f656f870d09901 Mon Sep 17 00:00:00 2001 From: Azalea Date: Sun, 28 May 2023 12:57:07 -0700 Subject: [PATCH] [+] Install-package --- scripts/zshrc.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/zshrc.sh b/scripts/zshrc.sh index 3694e73..a902629 100755 --- a/scripts/zshrc.sh +++ b/scripts/zshrc.sh @@ -111,6 +111,33 @@ alias jctl="sudo journalctl" alias ufw="sudo ufw" alias nginx="sudo nginx" +has() { + command -v "$1" &> /dev/null +} + +# Install using system package manager +install-package() { + if has pacman; then + pacman -Sy "$1" + elif has apt; then + apt install "$1" + elif has dnf; then + dnf install "$1" + elif has brew; then + brew install "$1" + fi +} + +# Set EDITOR +if has micro; then + export EDITOR="micro" +elif has nano; then + export EDITOR="nano" +else + install-package micro + export EDITOR="micro" +fi + # Gradle with auto environment detection [[ -z $GRADLE ]] && GRADLE="$(which gradle)" gradle() {