How do I keep functions/variables local to my zshrc?

zsh, zshrc

Solution

They are available, but they are not exported so scripts launching from command-line don’t get these variables. If your `.zshrc` looks like

function zshrc()
{
    local VAR=1
    # Do stuff
}
zshrc

and you then never want to launch `zshrc` function again you can just do

unfunction zshrc

afterwards.

Problem

Any variable that I declare in my `zshrc` is available in the shell as an environment variable. I don't want this to happen. I tried putting the variables in a function and setting them as local, but then the function is available outside of the `zshrc`. How can I make it so what happens in my zshrc stays in my zshrc?

Original source