Make direnv prompt updating conditional to direnv's presence

This commit is contained in:
anmiller 2024-05-15 15:45:24 +00:00
parent 53b3d7c419
commit 0f17f017eb

View File

@ -29,6 +29,7 @@ if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}"
fi fi
export ORIG_PS1=${PS1} export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then
update_prompt() { update_prompt() {
if direnv status | grep -iq 'RC allowed true'; then if direnv status | grep -iq 'RC allowed true'; then
PS1=${DIRENV_PS1} PS1=${DIRENV_PS1}
@ -37,6 +38,7 @@ update_prompt() {
fi 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} "