1
0
Files
dotfiles/.config/yadm/bootstrap.d/install-starship

39 lines
943 B
Bash
Executable File

#!/bin/bash
set -eu
source "${BOOTSTRAP_LIB}/helpers"
VERSION="1.16.0"
INSTALL_DIR="${HOME}/.local/bin"
INSTALLED_VERSION=""
if [[ -x "$(command -v starship)" ]]; then
INSTALLED_VERSION="$(starship -V | grep starship | grep -o '[0-9.]\+')"
fi
if [[ "$VERSION" == "$INSTALLED_VERSION" ]]; then
echo "Starship version ${VERSION} already installed."
exit 0
fi
echo "Installing starship version ${VERSION}..."
URL="https://github.com/starship/starship/releases/download/v${VERSION}/starship-x86_64-unknown-linux-gnu.tar.gz"
echo "Downloading from ${URL}..."
TARGET="$(download "$URL")"
if [[ -f "${INSTALL_DIR}/starship" ]]; then
echo "Removing old starship command..."
rm -f "${INSTALL_DIR}/starship"
fi
echo "Unpacking starship command to ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}"
tar --directory="${INSTALL_DIR}" -xf "${TARGET}" starship
chmod +x "${INSTALL_DIR}/starship"
echo "Removing ${TARGET}..."
rm -f "${TARGET}"