Add nix-shell prompt condition

This commit is contained in:
anmiller 2024-08-21 14:55:43 +00:00
parent 119c751ea3
commit bc63202425

View File

@ -23,15 +23,19 @@ fi
export PS1="${green}"'\$'"${no_color} " export PS1="${green}"'\$'"${no_color} "
export DIRENV_PS1="${red}"'\$'"${no_color} " export DIRENV_PS1="${red}"'\$'"${no_color} "
export NIX_SHELL_PS1="${blue}"'λ'"${no_color} "
if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then if [ "${HOSTNAME}" != "crypt" ] && [ "${HOSTNAME}" != "tomb" ] || [ "${SSH_TTY}" != "" ]; then
DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}" DIRENV_PS1="${DIRENV_PS1}${blue}${HOSTNAME} ${DIRENV_PS1}"
NIX_SHELL_PS1="${NIX_SHELL_PS1}${green}${HOSTNAME} ${NIX_SHELL_PS1}"
PS1="${PS1}${blue}${HOSTNAME} ${PS1}" PS1="${PS1}${blue}${HOSTNAME} ${PS1}"
fi fi
export ORIG_PS1=${PS1} export ORIG_PS1=${PS1}
if which direnv &> /dev/null; then if which direnv &> /dev/null; then
update_prompt() { 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} PS1=${DIRENV_PS1}
else else
PS1=${ORIG_PS1} PS1=${ORIG_PS1}