mirror of
https://github.com/nushell/nushell.git
synced 2025-07-09 02:48:17 +02:00
- fixes #14946 - related #15227 - > [When I run nushell with the hook, the hook itself works as expected, correctly detects system theme and changes $env.config.color_config. However, it seems that the change to $env.config.color_config is not propagated outside the hook](https://github.com/nushell/nushell/issues/15227#issuecomment-2695287318) - > [But it suffers from the same problem - modifications made to the $env.config variable are not visible outside of the hook (which I'm not sure if is correct behavior or bug).](https://github.com/nushell/nushell/issues/15227#issuecomment-2695741542) - > [I also managed to get it working with def --env, but there was one more issue, I had to change $env.config.hooks.pre_prompt = [{ switch_theme }] into $env.config.hooks.pre_execution = ([ switch_theme ])](https://github.com/nushell/nushell/issues/15227#issuecomment-2704537565) (having to use a string hook rather than a closure) - related #11082 > Might be possible solve or at least mitigate using a similar method # Description Recently realized that changes made to `$env.config` in closure hooks don't take effect whereas string hooks don't have that problem. After some investigation: - Hooks' environment was not preserved prior to #5982 > [2309601
](2309601dd4/crates/nu-cli/src/repl.rs (L823-L840)
) - `redirect_env` which properly updates the config state was implemented afterwards in #6355 > [ea8b0e8
](ea8b0e8a1d/crates/nu-engine/src/eval.rs (L174-L190)
) Simply using `nu_engine::eval::redirect_env` for the environment update was enough to fix the issue. # User-Facing Changes Hooks can update `$env.config` and the configuration change will work as expected. # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting N/A Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
Utilities used by the different nu-command
/nu-cmd-*
crates, should not contain any full Command
implementations.
Internal Nushell crate
This crate implements components of Nushell and is not designed to support plugin authors or other users directly.