Add install ripgrep script

main
Buddy Sandidge 3 years ago
parent df0f63bcc6
commit a51fe5c14f

@ -0,0 +1,36 @@
#!/usr/bin/env bash
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
function get_os () {
case $(uname -s) in
Linux*) echo unknown-linux-musl;;
Darwin*) echo apple-darwin;;
*) >&2 echo "unsupported os: $(uname -s)"; exit 1;;
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}"
URL=https://github.com/BurntSushi/ripgrep/releases/download/${VERSION}/ripgrep-${VERSION}-$(uname -m)-$(get_os).tar.gz
extract_tarball "${URL}" "${DEST}/${VERSION}" "--strip-component 1"
set_current_link "${DEST}" "${VERSION}"
set_link "${XDG_BIN_HOME}/rg" "${DEST}" rg
set_link "${MAN_DIR}/rg.1" "${DEST}" rg.1
set_link "${XDG_CONFIG_HOME}/bash/bashrc.d/ripgrep.sh" "${DEST}" complete/rg.bash
set_link "${XDG_CONFIG_HOME}/fish/functions/ripgrep.fish" "${DEST}" complete/rg.fish
Loading…
Cancel
Save