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

39 lines
992 B
Bash
Executable File

#!/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]\+\.[0-9]\+\.[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}"