Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cspotcode opened this issue Oct 10, 2019 · 5 comments
Open

Comments

@cspotcode
Copy link

cspotcode commented Oct 10, 2019

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.

@TudorAndrei
Copy link

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?

@bruno-
Copy link
Member

bruno- commented Nov 21, 2021

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

@cspotcode
Copy link
Author

cspotcode commented Nov 21, 2021 via email

@cgr71ii
Copy link

cgr71ii commented Oct 24, 2022

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?

@TudorAndrei
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants