tmux-plugins/tmux-resurrect

I made plugin that saves metadata along with panes (like env vars, etc)

cspotcode opened this issue · 5 comments

Some users want the ability to save pane-specific state, such as environment variables or a python virtualenv. When the pane is restored, they want this extra state to be restored as well.

I created https://github.com/cspotcode/tmux-resurrect-metadata to do this in a generic, reusable way. I took the code from https://github.com/ashb/tmux-resurrect-virtualenvwrapper and made it more generic. It will save and restore any tmux settings that start with @resurrect-metadata-. This can be used to save and restore session, pane, or window-specific values.

For example, your shell can call tmux set @tmux-resurrect-$TMUX_PANE-foo $someValue and it'll be automatically saved and restored when tmux-resurrect saves and restores the session. Your shell profile or default command is responsible for reading the values and doing something useful with them. (for example, setting the PATH, customizing the prompt, or setting a venv)

It's a work-in-progress. There needs to be a better mechanism for deleting pane-specific metadata values when the pane is closed, so they don't hang around and affect new panes.

Related to #109, #132, and #240. I hope this helps other people looking for the same thing.

I believe this could solve my issue with properly restoring the correct conda environment, by setting CONDA_PREFIX. Do you have an example, I couldn't understand from your example. Would it be possible to set the certain env var in the .tmux.conf?

@cspotcode consider adding your plugin to the list of plugins https://github.com/tmux-plugins/list

Hi! Couldn't this behaviour be added to the official plugin instead of creating a new one? The official plugins is being maintained, while the wrapper seems that won't be. I think that everyone may agree that the envvars are important, and since you might forget that you changed an envvar time ago, it might be relevant.

About conda, I'm also interested in know if only with the envvars is enough in order to don't break anything after the "resurrection".

Any thoughs?

About conda, I'm also interested in know if only with the envvars is enough in order to don't break anything after the "resurrection".
I think with conda it would be a bit more complicated as there are many envs that change during activation/deactivate and it would need some testing. I wasn't able to use the aforementioned plugin :(.

But having it in the official plugin would be very beneficial.