This commit is contained in:
Benjamin Palko 2024-09-30 23:14:13 -04:00
parent dde95a31ef
commit aed8ceea7e
3 changed files with 54 additions and 88 deletions

View file

@ -13,94 +13,64 @@
# Function: Is package installed # Function: Is package installed
# ------------------------------------------------------ # ------------------------------------------------------
_isInstalledPacman() { _isInstalledPacman() {
package="$1"; package="$1"
check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")"; check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")"
if [ -n "${check}" ] ; then if [ -n "${check}" ]; then
echo 0; #'0' means 'true' in Bash echo 0 #'0' means 'true' in Bash
return; #true return #true
fi; fi
echo 1; #'1' means 'false' in Bash echo 1 #'1' means 'false' in Bash
return; #false return #false
} }
_isInstalledYay() { _isInstalledYay() {
package="$1"; package="$1"
check="$(yay -Qs --color always "${package}" | grep "local" | grep "\." | grep "${package} ")"; check="$(yay -Qs --color always "${package}" | grep "local" | grep "\." | grep "${package} ")"
if [ -n "${check}" ] ; then if [ -n "${check}" ]; then
echo 0; #'0' means 'true' in Bash echo 0 #'0' means 'true' in Bash
return; #true return #true
fi; fi
echo 1; #'1' means 'false' in Bash echo 1 #'1' means 'false' in Bash
return; #false return #false
}
_isInstalledBrew() {
package="$1";
check="$(brew list | grep "${package} ")";
if [ -n "${check}" ] ; then
echo 0; #'0' means 'true' in Bash
return; #true
fi;
echo 1; #'1' means 'false' in Bash
return; #false
} }
# ------------------------------------------------------ # ------------------------------------------------------
# Function Install all package if not installed # Function Install all package if not installed
# ------------------------------------------------------ # ------------------------------------------------------
_installPackagesPacman() { _installPackagesPacman() {
toInstall=(); toInstall=()
for pkg; do for pkg; do
if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then
echo ":: ${pkg} is already installed."; echo ":: ${pkg} is already installed."
continue; continue
fi; fi
toInstall+=("${pkg}"); toInstall+=("${pkg}")
done; done
if [[ "${toInstall[@]}" == "" ]] ; then if [[ "${toInstall[@]}" == "" ]]; then
# echo "All pacman packages are already installed."; # echo "All pacman packages are already installed.";
return; return
fi; fi
# printf "Package not installed:\n%s\n" "${toInstall[@]}"; # printf "Package not installed:\n%s\n" "${toInstall[@]}";
sudo pacman --noconfirm -S "${toInstall[@]}"; sudo pacman --noconfirm -S "${toInstall[@]}"
} }
_installPackagesYay() { _installPackagesYay() {
toInstall=(); toInstall=()
for pkg; do for pkg; do
if [[ $(_isInstalledYay "${pkg}") == 0 ]]; then if [[ $(_isInstalledYay "${pkg}") == 0 ]]; then
echo ":: ${pkg} is already installed."; echo ":: ${pkg} is already installed."
continue; continue
fi; fi
toInstall+=("${pkg}"); toInstall+=("${pkg}")
done; done
if [[ "${toInstall[@]}" == "" ]] ; then if [[ "${toInstall[@]}" == "" ]]; then
# echo "All packages are already installed."; # echo "All packages are already installed.";
return; return
fi; fi
# printf "AUR packags not installed:\n%s\n" "${toInstall[@]}"; # printf "AUR packags not installed:\n%s\n" "${toInstall[@]}";
yay --noconfirm -S "${toInstall[@]}"; yay --noconfirm -S "${toInstall[@]}"
} }
_installPackagesBrew() {
toInstall=();
for pkg; do
if [[ $(_isInstalledBrew "${pkg}") == 0 ]]; then
echo ":: ${pkg} is already installed.";
continue;
fi;
toInstall+=("${pkg}");
done;
if [[ "${toInstall[@]}" == "" ]] ; then
echo "All brew packages are already installed.";
return;
fi;
brew install "${toInstall[@]}";
}

View file

@ -11,8 +11,3 @@ packagesPacman=(
packagesYay=( packagesYay=(
"emote" "emote"
) )
packagesBrew=(
"asdf"
"lazydocker"
)

View file

@ -6,6 +6,7 @@ packagesPacman=(
"git" "git"
"github-cli" "github-cli"
"lazygit" "lazygit"
"lazydocker"
"neofetch" "neofetch"
"ripgrep" "ripgrep"
"neovim" "neovim"