39 lines
906 B
Bash
Executable File
39 lines
906 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
source "${BOOTSTRAP_LIB}/helpers"
|
|
|
|
VERSION="1.4.1"
|
|
INSTALL_DIR="${HOME}/.local/bin"
|
|
INSTALLED_VERSION=""
|
|
|
|
if [[ -x "$(command -v glow)" ]]; then
|
|
INSTALLED_VERSION="$(glow --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')"
|
|
fi
|
|
|
|
if [[ "$VERSION" == "$INSTALLED_VERSION" ]]; then
|
|
echo "glow version ${VERSION} already installed."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Installing glow version ${VERSION}..."
|
|
|
|
URL="https://github.com/charmbracelet/glow/releases/download/v${VERSION}/glow_${VERSION}_linux_x86_64.tar.gz"
|
|
|
|
echo "Downloading from ${URL}..."
|
|
TARGET="$(download "$URL")"
|
|
|
|
if [[ -f "${INSTALL_DIR}/glow" ]]; then
|
|
echo "Removing old glow command..."
|
|
rm -f "${INSTALL_DIR}/glow"
|
|
fi
|
|
|
|
echo "Unpacking glow command to ${INSTALL_DIR}..."
|
|
mkdir -p "${INSTALL_DIR}"
|
|
tar --directory="${INSTALL_DIR}" -xf "${TARGET}" glow
|
|
chmod +x "${INSTALL_DIR}/glow"
|
|
|
|
echo "Removing ${TARGET}..."
|
|
rm -f "${TARGET}"
|