From aed8ceea7ec7649e5d292603820c8244f268ddb8 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Mon, 30 Sep 2024 23:14:13 -0400 Subject: [PATCH] library --- .install/includes/library.sh | 136 ++++++++++++++--------------------- .install/packages/general.sh | 5 -- .install/packages/shell.sh | 1 + 3 files changed, 54 insertions(+), 88 deletions(-) diff --git a/.install/includes/library.sh b/.install/includes/library.sh index 2c60a6b..15fa06a 100644 --- a/.install/includes/library.sh +++ b/.install/includes/library.sh @@ -1,106 +1,76 @@ #!/bin/bash -# _ _ _ -# | | (_) |__ _ __ __ _ _ __ _ _ -# | | | | '_ \| '__/ _` | '__| | | | -# | |___| | |_) | | | (_| | | | |_| | -# |_____|_|_.__/|_| \__,_|_| \__, | -# |___/ -# -# by Benjamin Palko [based on Stephan Raabe] (2023) -# ----------------------------------------------------- +# _ _ _ +# | | (_) |__ _ __ __ _ _ __ _ _ +# | | | | '_ \| '__/ _` | '__| | | | +# | |___| | |_) | | | (_| | | | |_| | +# |_____|_|_.__/|_| \__,_|_| \__, | +# |___/ +# +# by Benjamin Palko [based on Stephan Raabe] (2023) +# ----------------------------------------------------- # ------------------------------------------------------ # Function: Is package installed # ------------------------------------------------------ _isInstalledPacman() { - package="$1"; - check="$(sudo pacman -Qs --color always "${package}" | grep "local" | 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 + package="$1" + check="$(sudo pacman -Qs --color always "${package}" | grep "local" | 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 } _isInstalledYay() { - package="$1"; - check="$(yay -Qs --color always "${package}" | grep "local" | grep "\." | 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 -} - -_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 + package="$1" + check="$(yay -Qs --color always "${package}" | grep "local" | grep "\." | 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 # ------------------------------------------------------ _installPackagesPacman() { - toInstall=(); - for pkg; do - if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then - echo ":: ${pkg} is already installed."; - continue; - fi; - toInstall+=("${pkg}"); - done; + toInstall=() + for pkg; do + if [[ $(_isInstalledPacman "${pkg}") == 0 ]]; then + echo ":: ${pkg} is already installed." + continue + fi + toInstall+=("${pkg}") + done - if [[ "${toInstall[@]}" == "" ]] ; then - # echo "All pacman packages are already installed."; - return; - fi; + if [[ "${toInstall[@]}" == "" ]]; then + # echo "All pacman packages are already installed."; + return + fi - # printf "Package not installed:\n%s\n" "${toInstall[@]}"; - sudo pacman --noconfirm -S "${toInstall[@]}"; + # printf "Package not installed:\n%s\n" "${toInstall[@]}"; + sudo pacman --noconfirm -S "${toInstall[@]}" } _installPackagesYay() { - toInstall=(); - for pkg; do - if [[ $(_isInstalledYay "${pkg}") == 0 ]]; then - echo ":: ${pkg} is already installed."; - continue; - fi; - toInstall+=("${pkg}"); - done; + toInstall=() + for pkg; do + if [[ $(_isInstalledYay "${pkg}") == 0 ]]; then + echo ":: ${pkg} is already installed." + continue + fi + toInstall+=("${pkg}") + done - if [[ "${toInstall[@]}" == "" ]] ; then - # echo "All packages are already installed."; - return; - fi; + if [[ "${toInstall[@]}" == "" ]]; then + # echo "All packages are already installed."; + return + fi - # printf "AUR packags not installed:\n%s\n" "${toInstall[@]}"; - yay --noconfirm -S "${toInstall[@]}"; + # printf "AUR packags not installed:\n%s\n" "${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[@]}"; -} - diff --git a/.install/packages/general.sh b/.install/packages/general.sh index 6e4af18..c2ea4a9 100644 --- a/.install/packages/general.sh +++ b/.install/packages/general.sh @@ -11,8 +11,3 @@ packagesPacman=( packagesYay=( "emote" ) - -packagesBrew=( - "asdf" - "lazydocker" -) diff --git a/.install/packages/shell.sh b/.install/packages/shell.sh index ee39867..ee75a91 100644 --- a/.install/packages/shell.sh +++ b/.install/packages/shell.sh @@ -6,6 +6,7 @@ packagesPacman=( "git" "github-cli" "lazygit" + "lazydocker" "neofetch" "ripgrep" "neovim"