Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Scope of local parameters



Are there ways to limit the scope of local parameters besides
functions?  Say you want to colorize the prompt, and you use
helper variables for the color escape sequences:

  local RED=...
  local GREEN=...
  local BLUE=...

  PS1=<use RGB variables here>

If I do this in ~/.zshrc, or a file sourced by .zshrc, the
variables declared local do not disappear after sourcing ~/.zshrc.

One way to work around this is to wrap the PS1 initialization in
an auxiliary function, but then you have the same problem with
the scope of the function. :-)  Alternatively, one could

  unset RED GREEN BLUE

after setting PS1, but this doesn't feel quite right.  What if
the parameters RED GREEN BLUE already existed?  There has to be
a better way.

-- 
 Haakon



Messages sorted by: Reverse Date, Date, Thread, Author