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}"