It certainly is possible: any program you run has the permission to modify your .zshrc
. But in practice, of course, most programs won't do it.
Installers and configurations directly related to zsh are likely to modify .zshrc
, e.g. the installer for oh-my-zsh. This is pretty well justified: you're asking for it.
Some installers for software that come in the form of a shell script and are intended to be used on a user account modify the user's .bashrc
or .zshrc
. They do it to set up shell completions, PATH
entries, aliases, functions, etc. This is not always justified, and what they do isn't always compatible with your configuration. PATH
in particular shouldn't live in .zshrc
(any more than .bashrc
), but that mess is here to stay. Completions and functions are somewhat justified because there isn't a standard fpath
entry under the user's home directory.
In practice, I've seen that with installers for development environments, such as opam init
(which asks for confirmation) or nvm's install.sh
(which is just rude about it).
To keep track of what you've done manually, one possibility is to make ~/.zshrc
a very small file that just sources another file, e.g.
source ~/etc/zshrc
Then if everything else ever appears in ~/.zshrc
, you know that it's been added automatically.
Another approach is to keep your .zshrc
under version control. Then git diff
or the like will reveal uncommitted changes.
You can combine the two approaches.