Automatically restore virtualenv in on macOS (zsh, bash)

Ilya Kulakov kulakov.ilya at
Thu Jan 12 20:20:49 EST 2017

Today I discovered that one can customize session restoration in
by defining the shell_session_save_user_state function.

Here is a script that restores active virtualenv, e.g. after you reboot your machine:

It's written for ZSH, but it's fairly simple to port it to bash: you don't even need plugin,
since session management is supported out of the box.

Here is a plugin for oh-my-zsh:

More information about the Python-list mailing list