Move the once-per-session guard to the final extra-code section. Plain
and search variables can then refresh without rerunning arbitrary code.
Keep the extra body top-level so shell parse behavior stays unchanged.
Use an exported generation token for Zsh. Changes to generic or
Zsh-specific values reapply both layers, while unchanged nested shells
keep Zsh precedence and do not repeat self-references.
Plain values are re-evaluated each time the file is applied. Command
substitutions run again, and some self-references can change repeatedly.
Removing a variable still requires a new session.
Closes#3999Closes#4559