Skip to content

Commit d45f45b

Browse files
authored
fix: set PS1 in nix shells only (#205)
- outside of nix shells, e.g. when sourcing the env respect the user's env preferences (e.g. starship)
1 parent 41108ea commit d45f45b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/devshell.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,13 @@ in
409409

410410
# Set a cool PS1
411411
PS1 = stringAfter [ "PS1_util" ] (lib.mkDefault ''
412-
PS1='\[\033[38;5;202m\][${cfg.name}]$(rel_root)\$\[\033[0m\] '
412+
__set_prompt() {
413+
PS1='\[\033[38;5;202m\][${cfg.name}]$(rel_root)\$\[\033[0m\] '
414+
}
415+
# Only set the prompt when entering a nix shell, since nix shells
416+
# always reset to plain bash, otherwise respect the user's preferences
417+
[[ -n "''${IN_NIX_SHELL:-}" ]] && __set_prompt
418+
unset -f __set_prompt
413419
'');
414420
};
415421

0 commit comments

Comments
 (0)