How to reset a shell environment?

You could just exec zsh, which will give you a fresh zsh and re-run the init functions. Note that you'd need to exec zsh -l for a login zsh to keep its "login shell" status. I don't know how well it preserves command history (it seems to work for me, but if you use multiple shells in different terminals you might get 'crosstalk' between the two shells' history)


To undo exported environment variables, you can use the env command env -i zsh. env runs the command given as an argument, and -i gives it a clean environment.

Depending on your configuration, you may need to append -l to zsh / bash in order to load your .profile, and you also may need to "bootstrap" your environment with $HOME so that the shell knows where to find your startup files. Altogether, this looks like:

env -i HOME="$HOME" zsh -l