Use nicer prompt in bash when outside a nix shell

This commit is contained in:
Aleix Boné 2025-12-03 11:48:52 +01:00
parent fcc9719ccd
commit 02d9f5a062
No known key found for this signature in database

View File

@ -28,9 +28,22 @@
VISUAL = "vim";
};
programs.bash.promptInit = ''
PS1="\h\\$ "
'';
programs.bash.promptInit = # bash
''
if echo "$PATH" | grep -qc '/nix/store'; then
# Inside a nix shell, dumb prompt
PS1="\h\\$ "
elif [ "$TERM" != "dumb" ] ; then
PROMPT_COLOR="1;31m"
((UID)) && PROMPT_COLOR="1;32m"
PS1="\n\[\033[$PROMPT_COLOR\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\\$\[\033[0m\] "
if test "$TERM" = "xterm"; then
PS1="\[\033]2;\h:\u:\w\007\]$PS1"
fi
fi
'';
time.timeZone = "Europe/Madrid";
i18n.defaultLocale = "en_DK.UTF-8";