2

I'm using the tmux-resurrect plugin to recreate tmux sessions after tmux is shutdown. It mostly works but it is not restoring running commands. I've tried with vim, less, man and tail, all supported, but I get nothing but a waiting bash prompt.

Here's the save data for one pane that was running vim test.txt as seen in one of the save files in ~/.tmux/resurrect:

pane 0 1 :bash 1 :* 2 :/tmp 0 vim :

Clearly something is missing here. Where is "test.txt"? Pretty hard to recreate a command if the arguments aren't persisted.

Why aren't full commands being saved?

I am running this on Cygwin which I suspect is relevant.

2 Answers 2

1

The newer version does help with this:

https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_programs.md

I had to add the following to my .tmux.conf to make it work better:

# Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# Plugin Config
set -g @resurrect-processes 'python sqlite3 nano'
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-boot 'on'
set -g @continuum-restore 'on'

Fetch plugins + I (capital I)

Update plugins + U (capital U)

Save: + ctrl + s

Restore: + ctrl + r

The resultant dated save files can be edited at .tmux/resurrect

last is symbolic link to the last file, if tmux crashes on start up just cp a working / older one over the most recent that last is pointing to.

Some users find temporarily adding new-session at the start of .tmux.conf flushes things out.

source: https://jdhao.github.io/2019/01/17/tmux_plugin_management

0

The root of the problem is the hobbled version of ps that Cygwin provides because, in their words, due to the limitations of simulating a POSIX environment under Windows, there is little information to give. In particular this version of ps will not show command arguments. The solution is to install a more helpful substitute for ps and integrate it into tmux-resurrect.

Start by installing pgrep. This can be found in the Cygwin package psutils-ng (For 64-bit Cygwin. For 32-bit it might still be called just psutils.)

Now we need to tell tmux-resurrect to use it. Fortunately it already has a strategy available to use this tool. However, it's not quite compatible with the Cygwin version so edit the file [tmux-resurrect-install-dir]/save_command_strategies/pgrep.sh and change

\pgrep -lf -P "$PANE_PID" |

to

\pgrep -af -P "$PANE_PID" |

That's a single letter change, l to a.

Finally, tell the plugin to use this strategy by adding this line to your .tmux.conf file after any other resurrect configuration:

set -g @resurrect-save-command-strategy 'pgrep'

That should do it. Next time a session is saved the example given above should look more like this:

pane 0 1 :bash 1 :* 2 :/tmp 0 vim :vim test.txt

Upon restore that file will be loaded into vim.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .