gpakosz/.tmux

Vim/Nvim sessions not restored with tmux-resurrect

kamalmquist opened this issue · 5 comments

In my .tmux.conf.local I have this:

`
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'

`
However my vim/nvim sessions are not restored as expected after running tmux kill-server and restarting tmux.

I have the obsession.vim plugin installed in nvim and Session.vim is present.

These vim/nvim sessions restore just fine using a minimal normal .tmux.conf configuration that includes the above lines. However they are not restored when using "Oh My." The panes and the pane contents restore in this case, but not the actual vim/nvim sessions.

I can, however, manually restore the session by typing nvim -S.

Are there any known issues that would interfere with this functionality?

Edit: This may have to do with the way tmux-resurrect is storing its session information. Looking at the .tmux/resurrect/last file when not using "Oh My", the nvim session resolves to the correct command (I started it with "vi", which is a symbolic link to nvim), and the restore works great:

Screenshot 2023-12-27 at 2 03 27 AM

However, with "Oh My" installed, it resolves instead to just a bash shell, and the restore does not work:

Screenshot 2023-12-27 at 2 05 07 AM

Solved it. There is a section of the .tmux.conf file provided by "Oh My" that causes the trouble. Despite the appearance of this code all being commented out, it's actually being executed, due to some tricky stuff they're doing. To actually comment something out here, you have to double comment (##). And you need to change what they're doing in the case statement illustrated by the following picture:

Screenshot 2023-12-27 at 8 44 39 PM

Also see this thread from the tmux-resurrect project that helped me figure this out:

tmux-plugins/tmux-resurrect#72

Hopefully this helps somebody somewhere, somewhen.

Reopening in case there's an interest in implementing a more proper fix.

Hello @kamalmquist 👋

To actually comment something out here, you have to double comment (##). And you need to change what they're doing in the case statement illustrated by the following picture

The README.md file states:

❗️ You should never alter the main .tmux.conf or tmux.conf file. If you do, you're on your own. Instead, every customization should happen in your .tmux.conf.local or tmux.conf.local customization file copy.

All in all, I believe you should uninstall reattach-to-user-namespace that's not needed when using tmux 2.6+.

Right, I only modified it because that was the only way I could find to make the restore work. However, after uninstalling reattach-to-user-namespace everything worked, without needing to change the .tmux.conf. Maybe put this tip in the README? Thanks!

Sure,

I will keep this issue open until I remove the use of reattach-to-user-namespace entirely and raise the minimum tmux version to 2.6