From 02d9f5a062cb6ac437bc1344755ec4f9795819cd 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 8d5aef0b..bef1e937 100644 --- a/m/common/base/env.nix +++ b/m/common/base/env.nix @@ -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";