-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UX issue with nix-shell: No clean way to preserve my $PS1 #1268
Comments
I think this isn't even intentional. But maybe |
I'm using function restore_prompt_after_nix_shell() {
if [ "$PS1" != "$PROMPT" ]; then
PS1=$PROMPT
PROMPT_COMMAND=""
fi
}
PROMPT_COMMAND=restore_prompt_after_nix_shell
PROMPT='$ '
export PS1=$PROMPT |
Digging into this a little, I see that in Release 1.6 (2013-09-10): nix/doc/manual/release-notes/rl-1.6.xml Lines 35 to 37 in 6924bdf
and in Release 2.0 (2018-02-22) nix/doc/manual/release-notes/rl-2.0.xml Lines 566 to 573 in 906afed
The relevant code appears to be (from inspection, I haven't understood or tested this yet) nix/src/nix-build/nix-build.cc Line 449 in ea5bcfb
Is there any appetite for changing this to not set |
Fixes #1268 `nix-shell` will now preserve `PS1` if the `NIX_SHELL_PRESERVE_PROMPT` environment variable is set.
I have customized $PS1 with my personal notion of ideal usability, but nix-shell replaces it with one that is hard coded.
Is there some clean way to tell nix-shell which environment variables it should preserve? If not maybe nix-shell could benetif from flags like:
I think there is a way to preserve my customized PS1 variable with a --command 'export PS1=...' flag, but I'm already putting all of these nix-shell commands into a bash alias in my .bashrc, and I don't want to invest the time needed to figure out the proper escaping, and I don't want to have to edit and compile recompile nix-shell either.
This is only my second day with nix, not counting a few previous failed attempts to get into it over the years, so maybe this is something that is trivial to fix if you've already invested the time to learn the nix language...
The text was updated successfully, but these errors were encountered: