From b528b6f3ad079db41ddb88c8f2d09cc75749e480 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 11 May 2022 22:20:40 -0500 Subject: [PATCH] add install checks --- install | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/install b/install index df72f08..5aaa36b 100755 --- a/install +++ b/install @@ -85,23 +85,32 @@ install_tmux_plugin_manager () { install_starship () { - sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --force --bin-dir ${LOCAL_BIN_DIR} + starship --version >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --force --bin-dir ${LOCAL_BIN_DIR} + fi } install_direnv () { - set_kernal_and_machine_env_var - download_url=$( - curl -fL https://api.github.com/repos/direnv/direnv/releases/latest \ - | grep browser_download_url \ - | cut -d '"' -f 4 \ - | grep "direnv.$KERNAL.$MACHINE" - ) - curl -o "${LOCAL_BIN_DIR}/direnv" -fL "$download_url" - chmod +x "${LOCAL_BIN_DIR}/direnv" + direnv --version >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + set_kernal_and_machine_env_var + download_url=$( + curl -fL https://api.github.com/repos/direnv/direnv/releases/latest \ + | grep browser_download_url \ + | cut -d '"' -f 4 \ + | grep "direnv.$KERNAL.$MACHINE" + ) + curl -o "${LOCAL_BIN_DIR}/direnv" -fL "$download_url" + chmod +x "${LOCAL_BIN_DIR}/direnv" + fi } install_just () { - curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --force --to ${LOCAL_BIN_DIR} + just --version >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --force --to ${LOCAL_BIN_DIR} + fi } install_fzf () { @@ -109,13 +118,16 @@ install_fzf () { } install_gh_cli () { - set_kernal_and_machine_env_var - version=`curl "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-` - curl -sSL https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${KERNAL}_${MACHINE}.tar.gz -o gh_${version}_${KERNAL}_${MACHINE}.tar.gz - tar xvf gh_${version}_${KERNAL}_${MACHINE}.tar.gz - mv gh_${version}_${KERNAL}_${MACHINE}/bin/gh ${LOCAL_BIN_DIR}/gh - sudo mv gh_${version}_${KERNAL}_${MACHINE}/share/man/man1/* /usr/share/man/man1/ - chmod +x "${LOCAL_BIN_DIR}/gh" + gh --version >/dev/null 2>&1 + if [[ $? -ne 0 ]]; then + set_kernal_and_machine_env_var + version=`curl "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-` + curl -sSL https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${KERNAL}_${MACHINE}.tar.gz -o gh_${version}_${KERNAL}_${MACHINE}.tar.gz + tar xvf gh_${version}_${KERNAL}_${MACHINE}.tar.gz + mv gh_${version}_${KERNAL}_${MACHINE}/bin/gh ${LOCAL_BIN_DIR}/gh + sudo mv gh_${version}_${KERNAL}_${MACHINE}/share/man/man1/* /usr/share/man/man1/ + chmod +x "${LOCAL_BIN_DIR}/gh" + fi } copy_alacritty_config () {