Make direnv prompt updating conditional to direnv's presence

This commit is contained in:
Andrew R. M 2025-04-04 17:42:35 +00:00
parent 6d2071b1ea
commit 247417af95

View File

@ -29,14 +29,16 @@ if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}"
fi fi
export ORIG_PS1=${PS1} export ORIG_PS1=${PS1}
update_prompt() { if which direnv &> /dev/null; then
if direnv status | grep -iq 'RC allowed true'; then update_prompt() {
PS1=${DIRENV_PS1} if direnv status | grep -iq 'RC allowed true'; then
else PS1=${DIRENV_PS1}
PS1=${ORIG_PS1} else
fi PS1=${ORIG_PS1}
} fi
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND" }
PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND"
fi
# Continuation Prompt: "> " in cyan # Continuation Prompt: "> " in cyan
export PS2="${cyan}>${no_color} " export PS2="${cyan}>${no_color} "