feat: Direnv w/ poetry

This commit is contained in:
Price Hiller 2022-05-05 11:39:42 -05:00
parent 710f9f3b13
commit 999152c9de
2 changed files with 19 additions and 0 deletions

15
.config/direnv/direnvrc Normal file
View File

@ -0,0 +1,15 @@
#!/bin/zsh
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
exit 2
fi
# create venv if it doesn't exist
poetry run true
export VIRTUAL_ENV=$(poetry env info --path)
export POETRY_ACTIVE=1
PATH_add "$VIRTUAL_ENV/bin"
}

4
.zshrc
View File

@ -122,6 +122,10 @@ ZSH_AUTOSUGGEST_STRATEGY=(history completion)
# Enable fzf # Enable fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Direnv Hook
if which direnv >/dev/null 2>&1; then
eval "$(direnv hook zsh)"
fi
# Source the profile LAST # Source the profile LAST
source ~/.profile source ~/.profile