From f76aee15b33934177523dbc225392264781954a8 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Wed, 12 May 2021 13:48:27 -0700 Subject: [PATCH] Add direnv install and config --- direnv/.config/bash/bashrc.d/direnv.sh | 1 + direnv/.config/zsh/zshrc.d/direnv.zsh | 1 + direnv/.local/bin/install-direnv-home | 32 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 direnv/.config/bash/bashrc.d/direnv.sh create mode 100644 direnv/.config/zsh/zshrc.d/direnv.zsh create mode 100755 direnv/.local/bin/install-direnv-home diff --git a/direnv/.config/bash/bashrc.d/direnv.sh b/direnv/.config/bash/bashrc.d/direnv.sh new file mode 100644 index 0000000..885c279 --- /dev/null +++ b/direnv/.config/bash/bashrc.d/direnv.sh @@ -0,0 +1 @@ +eval "$(direnv hook bash)" diff --git a/direnv/.config/zsh/zshrc.d/direnv.zsh b/direnv/.config/zsh/zshrc.d/direnv.zsh new file mode 100644 index 0000000..6aa8b1f --- /dev/null +++ b/direnv/.config/zsh/zshrc.d/direnv.zsh @@ -0,0 +1 @@ +eval "$(direnv hook zsh)" diff --git a/direnv/.local/bin/install-direnv-home b/direnv/.local/bin/install-direnv-home new file mode 100755 index 0000000..225d93d --- /dev/null +++ b/direnv/.local/bin/install-direnv-home @@ -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}"