From e2a852d903cb37a82ce8a081e82aafbe1e3b5e0f Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Fri, 4 Jun 2021 22:10:34 -0700 Subject: [PATCH] Update starship for version 0.54 --- base/.local/share/buddy-up/includes/utils.sh | 6 +++ starship/.config/bash/bashrc.d/starship.sh | 3 +- starship/.config/starship.toml | 2 - starship/.config/zsh/zshrc.d/starship.zsh | 3 +- starship/.local/bin/install-starship-home | 54 +++++++++----------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/base/.local/share/buddy-up/includes/utils.sh b/base/.local/share/buddy-up/includes/utils.sh index 3f7802b..a13f831 100644 --- a/base/.local/share/buddy-up/includes/utils.sh +++ b/base/.local/share/buddy-up/includes/utils.sh @@ -74,6 +74,9 @@ extract_zip () { dest="${2}" args="${3}" sudo="${4}" + if [ -d "${dest}" ]; then + return + fi mkdir_if_missing "${dest}" "${sudo}" tmp_dir="$(mktemp -d)" @@ -89,6 +92,9 @@ extract_tarball () { dest="${2}" args="${3}" sudo="${4}" + if [ -d "${dest}" ]; then + return + fi mkdir_if_missing "${dest}" "${sudo}" tmp_dir="$(mktemp -d)" diff --git a/starship/.config/bash/bashrc.d/starship.sh b/starship/.config/bash/bashrc.d/starship.sh index b6ee6e8..048e6c8 100644 --- a/starship/.config/bash/bashrc.d/starship.sh +++ b/starship/.config/bash/bashrc.d/starship.sh @@ -1 +1,2 @@ -eval "$(starship init bash)" +# vim: ft=bash +source <(starship init bash) diff --git a/starship/.config/starship.toml b/starship/.config/starship.toml index 0bf36ca..6eb7a52 100644 --- a/starship/.config/starship.toml +++ b/starship/.config/starship.toml @@ -13,7 +13,6 @@ format = """\ """ [username] -style = "green" style_user = "green" format = "[$user]($style) " @@ -51,5 +50,4 @@ format = "[$duration]($style) " [character] success_symbol = "λ" -style_success = "" error_symbol = "[☠](red)" diff --git a/starship/.config/zsh/zshrc.d/starship.zsh b/starship/.config/zsh/zshrc.d/starship.zsh index af75929..d24a826 100644 --- a/starship/.config/zsh/zshrc.d/starship.zsh +++ b/starship/.config/zsh/zshrc.d/starship.zsh @@ -1 +1,2 @@ -eval "$(starship init zsh)" +# vim: ft=zsh +source <(starship init zsh) diff --git a/starship/.local/bin/install-starship-home b/starship/.local/bin/install-starship-home index 0497b7d..2ff75ee 100755 --- a/starship/.local/bin/install-starship-home +++ b/starship/.local/bin/install-starship-home @@ -1,37 +1,31 @@ #!/usr/bin/env bash -APP=starship -VERSION=${VERSION:-v0.47.0} -DATA_DIR="${XDG_DATA_HOME}/apps/releases" -DEST_DIR="${DATA_DIR}/${APP}/${VERSION}" +source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh" -OS= -ARCH= -case $(uname -s) in - Linux*) OS=unknown-linux-gnu;; - Darwin*) OS=apple-darwin;; - *) >&2 echo "unsupported os"; return; -esac +function get_os () { + case $(uname -s) in + Linux*) echo unknown-linux-gnu;; + Darwin*) echo apple-darwin;; + *) >&2 echo "unsupported os: $(uname -s)"; exit 1;; + esac +} -case $(uname -m) in - x86_64*) ARCH=x86_64;; - *) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;; -esac +function get_arch () { + case $(uname -m) in + x86_64*) echo x86_64;; + *) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;; + esac +} -URL="https://github.com/starship/starship/releases/download/${VERSION}/starship-${ARCH}-${OS}.tar.gz" -TMP_DIR= -if [[ ! -d "${DEST_DIR}" ]] ; then - TMP_DIR=$(mktemp --directory) - TAR_GZ="${TMP_DIR}/release.tar.gz" - curl --location --silent --output "${TAR_GZ}" "${URL}" - mkdir -p "${DEST_DIR}" - tar xzf "${TAR_GZ}" --directory "${DEST_DIR}" - rm -rf "${TMP_DIR}" -fi +APP=starship +VERSION=${VERSION:-0.54.0} +DEST="${XDG_DATA_HOME}/apps/releases/${APP}" +URL="https://github.com/starship/starship/releases/download/v${VERSION}/starship-$(get_arch)-$(get_os).tar.gz" -cd "${DATA_DIR}/${APP}" || exit -[[ -s current ]] && unlink current -ln -s "${VERSION}" current +extract_tarball "${URL}" "${DEST}/${VERSION}" +set_current_link "${DEST}" "${VERSION}" -cd "${XDG_BIN_HOME}" || exit -[[ -L "${APP}" ]] || ln --symbolic "${DATA_DIR}/${APP}/current/${APP}" ${APP} +cd "$XDG_BIN_HOME" || exit 1 +unlink_if_set "$XDG_BIN_HOME/${APP}" +ln -s "$(relative_path "${XDG_BIN_HOME}" "${DEST}/current/${APP}")" ${APP} +cd - >/dev/null || exit 1