1
0

add delta install script

This commit is contained in:
2022-07-18 08:42:14 +02:00
parent f448a58769
commit 714060e082

View File

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