Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This issue has been bugging me for a while, and although I've thought I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh.

I would like to replicate the things env-watcher does, to a lesser degree maybe, but I need to know if there is a command by which I could reset a shell to it's clean startup stage.

As for example, I'd like to have the following workflow.

source some-functions
alias another-thing
export SVN_EDITOR=vim
RESET-ZSH # none of the above are valid any more

Is there such a built in possibility, or am I chasing butterflies?

share|improve this question
up vote 17 down vote accepted

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)

share|improve this answer
Well that was simple :). Thanks. – mhitza Jun 13 '11 at 2:34
That wouldn't undo exported environment variables, would it? (Although any that get set by your init file would be reset.) – cjm Jun 13 '11 at 3:40
Probably it wouldn't. I hadn't considered that aspect because I wasn't thinking of environment variables as something you set temporarily in the shell. – Random832 Jun 13 '11 at 3:42

I know I'm a little late to the party, but 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.

Hope that helps someone!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.