tmux-resurrect icon indicating copy to clipboard operation
tmux-resurrect copied to clipboard

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

Open cspotcode opened this issue 6 years ago • 5 comments
trafficstars

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.

cspotcode avatar Oct 10 '19 16:10 cspotcode

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?

TudorAndrei avatar Nov 20 '21 23:11 TudorAndrei

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

bruno- avatar Nov 21 '21 09:11 bruno-

Unfortunately I don't have time to maintain a plugin these days. But if anyone wants to fork or maintain it, let me know.

On Sun, Nov 21, 2021, 4:41 AM Bruno Sutic @.***> wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tmux-plugins/tmux-resurrect/issues/312#issuecomment-974784267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC35OHJ2MJQEZWLXCLZEIDUNC5FXANCNFSM4I7PJXMQ .

cspotcode avatar Nov 21 '21 16:11 cspotcode

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?

cgr71ii avatar Oct 24 '22 12:10 cgr71ii

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.

TudorAndrei avatar Oct 24 '22 14:10 TudorAndrei