Update fzf script

main
Buddy Sandidge 3 years ago
parent 79994293d0
commit 8e73c4c778

@ -1,4 +1,4 @@
#ft=sh
#ft=bash
bail () {
>&2 echo "ERROR: $1"
@ -11,6 +11,18 @@ must_be_root () {
fi
}
set_link () {
TARGET="$1"
APP_DIR="$2"
APP_PATH="$3"
pushd "$(dirname "${TARGET}")" >/dev/null || exit 1
unlink_if_set "${TARGET}"
REL_PATH=$(relative_path "$(dirname "${TARGET}")" "${APP_DIR}/current/${APP_PATH}")
ln -s "${REL_PATH}" "$(basename "${TARGET}")"
popd >/dev/null || exit 1
}
get_os () {
case $(uname -s) in
Linux*) echo linux;;

@ -1,38 +1,12 @@
#!/usr/bin/env bash
APP=fzf
VERSION=${VERSION:-0.24.4}
DATA_DIR="${XDG_DATA_HOME}/apps/releases"
DEST_DIR="${DATA_DIR}/${APP}/${VERSION}"
OS=
ARCH=
case $(uname -s) in
Linux*) OS=linux;;
Darwin*) OS=darwin;;
*) >&2 echo "unsupported os"; return;
esac
case $(uname -m) in
x86_64*) ARCH=amd64;;
*) >&2 echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
URL="https://github.com/junegunn/fzf/releases/download/${VERSION}/fzf-${VERSION}-${OS}_${ARCH}.tar.gz"
TMP_DIR=
if [[ ! -d "${DEST_DIR}" ]] ; then
TMP_DIR=$(mktemp --directory)
TAR_GZ="${TMP_DIR}/release.tar.gz"
curl --location --silent --output "${TAR_GZ}" "${URL}"
mkdir -p "${DEST_DIR}"
tar xzf "${TAR_GZ}" --directory "${DEST_DIR}"
rm -rf "${TMP_DIR}"
fi
cd "${DATA_DIR}/${APP}" || exit
[[ -s current ]] && unlink current
ln -s "${VERSION}" current
APP=fzf
VERSION=${VERSION:-0.27.2}
DEST="${XDG_DATA_HOME}/apps/releases/${APP}"
URL=https://github.com/junegunn/fzf/releases/download/${VERSION}/fzf-${VERSION}-$(get_os)_$(get_arch).tar.gz
cd "${XDG_BIN_HOME}" || exit
[[ -L "${APP}" ]] || ln --symbolic "${DATA_DIR}/${APP}/current/${APP}" ${APP}
extract_tarball "${URL}" "${DEST}/${VERSION}"
set_current_link "${DEST}" "${VERSION}"
set_link "${XDG_BIN_HOME}/${APP}" "${DEST}" "${APP}"

@ -10,18 +10,6 @@ function get_os () {
esac
}
function set_link () {
TARGET="$1"
APP_DIR="$2"
APP_PATH="$3"
pushd "$(dirname "${TARGET}")" || exit 1
unlink_if_set "${TARGET}"
REL_PATH=$(relative_path "$(dirname "${TARGET}")" "${APP_DIR}/current/${APP_PATH}")
ln -s "${REL_PATH}" "$(basename "${TARGET}")"
popd || exit 1
}
APP=rg
VERSION=${VERSION:-13.0.0}
DEST="${XDG_DATA_HOME}/apps/releases/${APP}"
@ -34,4 +22,3 @@ set_link "${XDG_BIN_HOME}/rg" "${DEST}" rg
set_link "${MAN_DIR}/rg.1" "${DEST}" doc/rg.1
set_link "${XDG_CONFIG_HOME}/bash/bashrc.d/ripgrep.sh" "${DEST}" complete/rg.bash
set_link "${XDG_CONFIG_HOME}/fish/completions/ripgrep.fish" "${DEST}" complete/rg.fish

Loading…
Cancel
Save