diff options
author | Jamie Quigley <jamie@quigley.xyz> | 2023-02-01 20:43:26 +0000 |
---|---|---|
committer | Jamie Quigley <jamie@quigley.xyz> | 2023-02-01 20:50:44 +0000 |
commit | 32ca59649b0af8d8d77905274fe63de3a3fc0d1e (patch) | |
tree | 855a0d6f577a4dd9561a681865afb06732e6862e | |
parent | 119ba50eb840d812d7175cdc105d9e38dabb5773 (diff) |
nix-shell: Colour the prompt red if the user is root
This matches the nixos prompt colours - green for standard user, red for
root
-rw-r--r-- | src/nix-build/nix-build.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 049838bb1..da76c2ace 100644 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -536,7 +536,9 @@ static void main_nix_build(int argc, char * * argv) "SHELL=%5%; " "BASH=%5%; " "set +e; " - R"s([ -n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '; )s" + R"s([ -n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && )s" + + (getuid() == 0 ? R"s(PS1='\n\[\033[1;31m\][nix-shell:\w]\$\[\033[0m\] '; )s" + : R"s(PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '; )s") + "if [ \"$(type -t runHook)\" = function ]; then runHook shellHook; fi; " "unset NIX_ENFORCE_PURITY; " "shopt -u nullglob; " |