Add sessionVariablesOnce to home-env, bash and zsh #6594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There are some issues about users that expect their environment variables to change when they change their
sessionVariables
in their config files. I am one of them.I learned twice the hard way that they are only sourced once per session and for me this is quite unintuitive. I thought sessions always start fresh and all variables are set at the beginning always.
F.e. when opening a new terminal with zsh, the sessionVariables are not set after they are changed, but only after logging out and in entirely.
In fact, bash did not have the same behavior, making me think that maybe zsh shouldn't even have this in the first place. Happy to amend this change to drop the "only once" behavior from zsh program entirely.
As for home session vars, I think it might make sense, and I added a field explicitly for this purpose,
sessionVariablesOnce
. This solution was suggested here by user @Bujiraso.Checklist
Unfortunately, people expecting the
Once
behavior for their regular variables might end up with very long variables in the end, but since this is mostly used for PATH-like variables, this will not break any functionality. So IMO this is backwards compatible enough.Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
or
nix build --reference-lock-file flake.lock ./tests#test-all
using Flakes.They both seem broken. They error on stuff totally unrelated to my changes.
Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
Maintainer CC
@rycee (no maintainers for
programs.zsh
)