So I’m trying to get my nix-shell PS1 prompt to tell me that I’m in a nix-shell
I tried
shellHook = ‘export PS1="$PS1:nix-shell> "’;
but I think my bashrc is probably overriding it, how do others set their PS1 as part of a nix-shell session? I never know if I’m ‘in’ or ‘out’
You could check for $IN_NIX_SHELL inside your bashrc:
$IN_NIX_SHELL
if [[ -n "$IN_NIX_SHELL" ]]; then export PS1="$PS1:nix-shell>" fi
I use this one in the shellHook of shell.nix for example: shellHook = "export PS1='\n\[\033[1;34m\][${name}:\w]\$\[\033[0m\]' " It changes the prompt color and also shows the name of the derivation to indicate where I am.
shellHook
shell.nix
shellHook = "export PS1='\n\[\033[1;34m\][${name}:\w]\$\[\033[0m\]' "
cool,
I settled on
if [[ -n "$IN_NIX_SHELL" ]]; then prompt_tag "(nix-shell)" fi
where prompt_tag is from liquidprompt
prompt_tag
liquidprompt