You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoiding CMD_DURATION_MS and LAST_EXIT_CODE env vars #9276
nushell sets two environment variables for use with custom prompts:
CMD_DURATION_MS
LAST_EXIT_CODE
As a side-effect, this litters the environment for all programs run from nushell, unlike other shells where a local variable is used that prompt functions can check.
Describe the solution you'd like
Pass this information through either:
Globally accessible non-environment variables.
Provide a built-in command to obtain this information in PROMPT_* functions when/if needed.
Provide this information as argument to the PROMPT_* functions.
I am leaning towards 2.
Describe alternatives you've considered
ENV_CONVERSIONS hacks to filter out the value crossed my mind, but the idea seemed ugly.
I wonder if hiding within a scope is a better way to do this. We'd have to play a bit though. The idea being, prior to launch do a hide or hide-env of whatever you don't want. I did some quick testing and couldn't get it to work either.
But it does demonstrate just how many environment variables we are exporting (a.k.a. polluting) into the child process.
I'm not sure there's any good justification for most of these to be environment variables. They aren't in other shells, so third-party apps like Starship just call itself using something like (copied from the init):
Since they can't count on a shell having environment variables, they just get the value the easiest way and pass it as an argument. So (in theory) we could convert these to commands as mentioned in the original issue (item 2).
Both variables are still exported to child processes of the REPL on 0.117. #15533 was opened from this issue and tracks them together with the prompt and NU_* variables.
Activity
fdncred commentedon May 24, 2023
Or write your own custom
envcommand like I have. You'd have to change it to filter out whatever you don't want.kennylevinsen commentedon May 24, 2023
The intent would be to exclude these variables in the environment of spawned programs, which an env command would unfortunately not help with.
fdncred commentedon May 24, 2023
I wonder if hiding within a scope is a better way to do this. We'd have to play a bit though. The idea being, prior to launch do a
hideorhide-envof whatever you don't want. I did some quick testing and couldn't get it to work either.NotTheDr01ds commentedon Apr 2, 2025
The following works, as long as I'm not running Tmux (and I'm not quite sure why Tmux is different yet):
But it does demonstrate just how many environment variables we are exporting (a.k.a. polluting) into the child process.
I'm not sure there's any good justification for most of these to be environment variables. They aren't in other shells, so third-party apps like Starship just call itself using something like (copied from the init):
Since they can't count on a shell having environment variables, they just get the value the easiest way and pass it as an argument. So (in theory) we could convert these to commands as mentioned in the original issue (item 2).
kronberger-droid commentedon Nov 14, 2026
Both variables are still exported to child processes of the REPL on 0.117.
#15533 was opened from this issue and tracks them together with the prompt and
NU_*variables.