tmux-plugins / tmux-resurrect

Persists tmux environment across system restarts.
MIT License
11.42k stars 424 forks source link

Resurrect only saves current session #347

Closed rajeshisnepali closed 4 years ago

rajeshisnepali commented 4 years ago

I had two sessions having 2 windows in each. Before the shutdown, I pressed prefix+Ctrl+S to save my sessions.

After reboot, Pressing prefix+Ctrl+R only restored the session in which I saved the session. Does it not save all the sessions?

sqqqrly commented 4 years ago

This is working for me. I am on the current HEAD.

Before you save via resurrect, verify tmux sees two or more sessions using leader + s.

Examine ~/.tmux/resurrect/last. Does the file list sessions? At the bottom, there is a "state" line that for me, lists my two sessions.

state macbook webinar

Are you creating sessions using sockets? tmux -S /tmp/shared new -s {sessionName}

rajeshisnepali commented 4 years ago

Here's my ~/.tmux/resurrect/last output image

Unfortunately, it is not listing my "general" session. And do you know if resurrect saves any session automatically (without prefix+s)?

Are you creating sessions using sockets? tmux -S /tmp/shared new -s {sessionName}

No, I normally create the session using tmux new -s {session_name}

sqqqrly commented 4 years ago

Well, afraid I am of little help. This is working for me. It is also working on several other OSs for me.

jiaming10 commented 4 years ago

I tried this too and it is working for me as well. Is it possible to list out the commands you run step by step so we can try to follow and see what is missing?

rajeshisnepali commented 4 years ago

My ~/.tmux.conf

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Other examples:
set -g @plugin 'tmux-plugins/tmux-resurrect'
# set -g @plugin 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'

I had 2 sessions. I went to one of those sessions (probably the second one). I then hit prefix+Ctrl+S. After reboot, I opened a new tmux session simply by executing tmux, and then I hit prefix+Ctrl+R to get my sessions back.

I did only get the session in which I had pressed the command.

Please let me know if you need additional information.

jiaming10 commented 4 years ago

Can you perform following steps:

  1. Make sure you have created the sessions you need.
  2. Run prefix + W, and screenshot the output.
  3. Save the sessions prefix+Ctrl+S
  4. Kill the tmux server. tmux kill-server.
  5. Run tmux.
  6. Restore the sessions prefix+Ctrl+R
  7. Run prefix + W, and screenshot the output.
rajeshisnepali commented 4 years ago

Step No. 2 tmux_all_windows

Step No. 7 tmux_all_windows_after

@jiaming10 I'd also like to add few things. I rarely shut-down my laptop (once a week). The last time I saved & restored the tmux session worked fine. I think this issue arose before 2 shutdowns.

I think this should work fine. Perhaps, back then will be some kind of glitch. I'll be shutting down my laptop tonight. So I will give you the output tomorrow.

rajeshisnepali commented 4 years ago

@jiaming10 I think it works fine now.

How do I clear my existing saved tmux sessions? Will removing ~/.tmux/resurrect/last or manually deleting sessions & then saving only one session work?

jiaming10 commented 4 years ago

I think the best way to do is manually create/delete sessions,windows,pane, until a state that you prefer. Then you save it.

By saving each time, ~/.tmux/resurrect/last's content will backup to another file before it gets overwritten, you can verify this in ~/.tmux/resurrect folder. This will help you if you wanted to go back to a saved state previously, in case you have a change of mind.