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?
If you're using a recent version of zsh you can use an anonymous function:
function () {
local xyz=abc
# whatever
}
The function will be automatically executed and then thrown away, it exists only for scoping purposes.
This works for any sourced file, not only zshrc.