From 2f17161f594c210949d437555b71f02465aa185c Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sat, 1 Apr 2017 21:48:38 -0700 Subject: [PATCH] Add direnv-hook to promp if exists --- bash/direnv-hook | 11 +++++++++++ bashrc | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 bash/direnv-hook diff --git a/bash/direnv-hook b/bash/direnv-hook new file mode 100644 index 0000000..38a118b --- /dev/null +++ b/bash/direnv-hook @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +_direnv_hook() { + eval "$(direnv export bash)"; +}; + +if type direnv > /dev/null; then + if ! [[ "$PROMPT_COMMAND" =~ _direnv_hook ]]; then + PROMPT_COMMAND="_direnv_hook;$PROMPT_COMMAND"; + fi +fi diff --git a/bashrc b/bashrc index 8bbe045..ab44236 100644 --- a/bashrc +++ b/bashrc @@ -43,3 +43,7 @@ fi if [ -f ~/.bash/prompt ]; then source ~/.bash/prompt fi + +if [ -f ~/.bash/direnv-hook ]; then + source ~/.bash/direnv-hook +fi