Add nix-shell prompt condition

This commit is contained in:
Andrew R. M 2025-04-04 17:43:05 +00:00
parent 5c7fbbd20f
commit db55b56b85

View File

@ -23,15 +23,19 @@ fi
export PS1="${green}"'\$'"${no_color} "
export DIRENV_PS1="${red}"'\$'"${no_color} "
export NIX_SHELL_PS1="${blue}"'λ'"${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
NIX_SHELL_PS1="${NIX_SHELL_PS1}${green}${HOSTNAME} ${NIX_SHELL_PS1}"
PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
fi
export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then
update_prompt() {
if direnv status | grep -iEq 'RC allowed (true|0)'; then
if [ -n "${IN_NIX_SHELL}" ]; then
PS1=${NIX_SHELL_PS1}
elif direnv status | grep -iEq 'RC allowed (true|0)'; then
PS1=${DIRENV_PS1}
else
PS1=${ORIG_PS1}