Add direnv install and config

main
Buddy Sandidge 4 years ago
parent 3acc30f058
commit f76aee15b3

@ -0,0 +1 @@
eval "$(direnv hook bash)"

@ -0,0 +1 @@
eval "$(direnv hook zsh)"

@ -0,0 +1,32 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
APP=direnv
VERSION=${VERSION:-2.28.0}
DATA_DIR="${XDG_DATA_HOME}/apps/releases"
DEST_DIR="${DATA_DIR}/${APP}/${VERSION}"
URL=https://github.com/direnv/direnv/releases/download/v${VERSION}/direnv.$(get_os)-$(get_arch)
if [[ ! -d "${DEST_DIR}" ]] ; then
TMP_DIR=$(mktemp -d)
OUTPUT="${TMP_DIR}/${APP}"
curl --location --silent --output "${OUTPUT}" "${URL}"
mkdir -p "${DEST_DIR}"
chmod 755 "${OUTPUT}"
mv -v "${OUTPUT}" "${DEST_DIR}/${APP}"
rm -rf "${TMP_DIR}"
fi
cd "${DATA_DIR}/${APP}" || exit 1
[[ -s current ]] && unlink current
ln -s "${VERSION}" current
if [[ -L "$XDG_BIN_HOME/${APP}" ]]; then
unlink "$XDG_BIN_HOME/${APP}"
fi
cd "${XDG_BIN_HOME}" || exit 1
REL_LINK="$(relative_path "${XDG_BIN_HOME}" "${DATA_DIR}/${APP}/current/${APP}")"
[[ -L "${APP}" ]] || ln -s "${REL_LINK}" "${APP}"
Loading…
Cancel
Save