gnzh theme: fix "eval" and related scope problems. #4113
Merged
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.
Fixes #3425.
This clears up issues related to
eval
and the use of eager vs lazy evaulation in thegnzh
theme. Theeval
was the one causing user-visible problems, but there's a small tangle of related issues, and this addresses them all.The outcome of this PR is that:
%F
/%f
$PROMPT
string are all eager-evaluated at theme loading time$(...)
to call functions at prompt timelocal
-izedThis PR removes the problematic
eval
usage by switching to normalzsh
%F/%f prompt escapes to avoid "eval" and the associated global variables.There were several
local
statements that weren't having any effect, because the theme is not loaded in a function, so they were globals. This PR wraps whole thing in an anonymous function so the existinglocal
statements actually work.But that breaks the theme, because a lot of stuff was done with lazy-evaluated
'...'
quotes, which relied on those actually being persistent global variables. So this PR switches '...' to eager "..." where needed, so stuff actually works with local variables.And it
local
-izes the remaining variables that are used only in prompt construction.I've tested this on the following, exercising the git, return status, and root detection features, and it looks good.
xterm
, andurxvt
Could use some more testers for
urxvt
and the console on Linux distros that were having this problem, and for RVM.