From 6fbf267f9d164b421a4a90a91f8f685c613c7895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Bon=C3=A9?= Date: Wed, 3 Dec 2025 11:48:52 +0100 Subject: [PATCH] Use nicer prompt in bash when outside a nix shell --- m/common/base/env.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/m/common/base/env.nix b/m/common/base/env.nix index 5efc277d..bff8ca02 100644 --- a/m/common/base/env.nix +++ b/m/common/base/env.nix @@ -53,9 +53,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";