Created
February 4, 2022 15:57
-
-
Save thepigeonoftime/4d90d62316f3f343d3052e0cfa541171 to your computer and use it in GitHub Desktop.
ZSH .direnv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U add-zsh-hook | |
load-dir-env() { | |
if [[ -f .direnv && -r .direnv ]]; then | |
if [[ $(history | tail -n1 | awk '{print $2}') == *"cd"* ]]; then | |
print -P "%F{red}.direnv loaded: $(head -n1 .direnv | sed 's/#\s//')%f" | |
fi | |
source .direnv | |
fi | |
} | |
add-zsh-hook chpwd load-dir-env | |
add-zsh-hook precmd load-dir-env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment