0

nix-shell changes PS1 to its own format.

 [nix-shell:~/snm]$ 

I tried adding check for "$IN_NIX_SHELL" inside ~/.bashrc, but it didn't work.

The only work around I found is to run

nix-shell --run bash
3
  • What is the PS1 that you want to keep, and where do you set it? Not knowing much about nix-shell, it seems obvious to me that if you run another shell, it may set its own prompt. You may want to look into how to configure the prompt for that shell.
    – they
    Jan 14 at 14:26
  • my PS1 in set in ~/.bashrc, but nix-shell uses its own unless i explicitly tell it to run bash.
    – andreoss
    Jan 14 at 18:49
  • But having it run bash kinda defeats the purpose of running nix-shell, doesn't it? Why don't you just configure the prompt you want to use in the nix-shell? Or, alternatively, just use bash. Note that I don't quite know what nix-shell is, but am assuming it's a shell like any other.
    – they
    Jan 14 at 19:21

1 Answer 1

0

Since Nix 2.4 [1] there is NIX_SHELL_PRESERVE_PROMPT environment variable which makes nix-shell preserve original PS1. It can be added by

  home.sessionVariables = {
    NIX_SHELL_PRESERVE_PROMPT=1;
  };

1: https://discourse.nixos.org/t/nix-2-4-released/15822

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.