How to get tmux resurrect to restore neovim sessions

I came across the same issue and the problem is with the way that tmux-resurrect saves the names of the process it later needs to resurrect, This issue is not specific to NixOS and is caused once the name of the process deviates from the one tmux-resurrect plugin expects when it parses its state file(file named last that points at some tmux_resurrect_*).

The workaround is to leverage a tmux-resurrect hook that will be triggered each time tmux state is saved. I ended adding the
following 4 lines to the configurations of the tmux-resurrect plugin
as will be in the generated .tmux.conf

resurrect_dir=“$HOME/.tmux/resurrect”
set -g @resurrect-dir $resurrect_dir
set -g @resurrect-hook-post-save-all ‘target=$(readlink -f $resurrect_dir/last); sed “s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g” $target | sponge $target’

You can see the actual code in my repo

2 Likes