From 4ef1d159589b83571c9c2d83d87b2ed0761b27d5 Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Sat, 5 Apr 2025 16:37:09 -0400 Subject: [PATCH] Make direnv prompt updating conditional to direnv's presence --- bash/.bashrc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index 102bd56..ddabf3b 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -29,14 +29,16 @@ if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" fi export ORIG_PS1=${PS1} -update_prompt() { - if direnv status | grep -iq 'RC allowed true'; then - PS1=${DIRENV_PS1} - else - PS1=${ORIG_PS1} - fi -} -PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND" +if which direnv &> /dev/null; then + update_prompt() { + if direnv status | grep -iq 'RC allowed true'; then + PS1=${DIRENV_PS1} + else + PS1=${ORIG_PS1} + fi + } + PROMPT_COMMAND="update_prompt; $PROMPT_COMMAND" +fi # Continuation Prompt: "> " in cyan export PS2="${cyan}>${no_color} "