1
0

add starship install script

This commit is contained in:
2022-07-15 23:20:05 +02:00
parent 77160c7b20
commit e8252b1a1a

View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -eu
VERSION="1.9.1"
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 [[ -d "${INSTALL_DIR}" ]] ; 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"