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?
precmd is executed before your prompt is displayed and is often used to set values in your $PROMPT . preexec is executed between when you press enter on a command prompt but before the command is executed. Each hook is an array of widgets which are executed by zsh.
The autoload command essentially instructs Zsh to register a function (called clock) using the contents of the clock file that is located in a directory somewhere along the fpath.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With