diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh index eb3ae6b0e..bc84f39e8 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -70,8 +70,8 @@ function _omz_load_theme_from_file() { values_before[$param]=${(P)param} done - # Actually load the theme - source $file + # Actually load the theme, using an indirection function + _omz_source_theme_file $file # Debugging stuff if [[ $ZSH_THEME_DEBUG == true ]]; then @@ -128,6 +128,14 @@ function _omz_load_theme_from_file() { fi } +# Sources the given file +# The only reason this function exists is to provide a layer of +# indirection so that the theme file runs in its own function call stack frame +# and "local" statements in the theme definitions work as intended. +function _omz_source_theme_file() { + source $1 +} + # Resets all theme settings to their default state # (To the extent that we know what themes do, that is.) # This will reset all variables used by the core OMZ *_prompt_info functions.