Added conditional coloring of bash prompt dependent on direnv status

This commit is contained in:
Andrew R. M 2025-04-04 17:42:35 +00:00
parent d682e91d6d
commit 8e1877f9e8

View File

@ -12,9 +12,21 @@ no_color="\001$(tput sgr0)\002"
export PS1="${green}\$${no_color} "
export DIRENV_PS1="${red}\$${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
DIRENV_PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
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"
# Continuation Prompt: "> " in cyan
export PS2="${cyan}>${no_color} "