1
0
Fork 0
mirror of https://github.com/hcartiaux/dotfiles.git synced 2024-10-18 17:25:23 +02:00
dotfiles/direnv/init.sh
Hyacinthe Cartiaux 5fc6e57ec7 [direnv] simplify
2020-05-13 19:01:57 +02:00

21 lines
589 B
Bash

# Custom load for direnv
# See https://direnv.net/
if [ -n "$(which direnv 2>/dev/null)" ]; then
current_shell=$(ps -p $$ | awk '$1 != "PID" {print $(NF)}')
eval "$(direnv hook $current_shell)" || true
# See https://github.com/direnv/direnv/wiki/Python#restoring-the-ps
show_virtual_env() {
if [[ -n "$VIRTUAL_ENV" && -n "$DIRENV_DIR" ]]; then
echo "($(basename $VIRTUAL_ENV))"
fi
}
if [[ -n ${ZSH_VERSION-} ]]; then
setopt PROMPT_SUBST
else
export -f show_virtual_env
fi
PS1='$(show_virtual_env) '$PS1
fi