greymd / tmux-xpanes

Awesome tmux-based terminal divider
MIT License
1.96k stars 61 forks source link

"Recover" session over ssh? #114

Closed dzg closed 5 years ago

dzg commented 5 years ago

Say I launch xpanes while logged into remote machine with ssh. Then I log out of ssh. Then re-connect.

xpanes/tmux is still running; how can I recover my session?

tmux ls says no server running

Thanks!

greymd commented 5 years ago

xpanes creates the ~/.cache/xpanes/socket file as a default session file [doc].

Can you try this command?

tmux -S ~/.cache/xpanes/socket ls

If you are using tmux v3.1.1, ~/.cache/xpanes/socket.<PID> is used instead.

dzg commented 5 years ago

That works!

I was able to re-attach session with tmux -S ~/.cache/xpanes/socket a

Thanks!

dzg commented 5 years ago

Is it possible to attach to the same session from another user from another machine? It's not working for me; I get no sessions:

[user1@host1] $ xpanes -S /SharedNetworkVolume/sockets/socket1 a b c d
[user2@host2] $ tmux -S /SharedNetworkVolume/sockets/socket1 attach
no sessions
greymd commented 5 years ago

As far as I know, it is impossible to share the same session within different hosts. This is because of the tmux's limitation.

I found similar discussion link.

greymd commented 5 years ago

Let me close this issue for now. But if you have further questions, please re-open this issue anytime 👍

fauust commented 4 years ago

Hi, I am unable to recover a xpanes session locally:

❯ ls ~/.cache/xpanes/
socket.19022
❯ tmux -S ~/.cache/xpanes/socket.19022 attach
no sessions

What am I doing wrong?

greymd commented 4 years ago

Hi, Can you try tmux attach -t <target session> if you get any results from tmux ls command ?

xpanes creates the session file under ~/.cache/xpanes/socket.. However, when xpanes is executed in the existing tmux session, this socket file is not created. Instead, default tmux session file is used.

fauust commented 4 years ago

Hi, Can you try tmux attach -t <target session> if you get any results from tmux ls command ?

Only 2 tmux sessions launched at login (from tmux). And I am able to attach those one.

xpanes creates the session file under ~/.cache/xpanes/socket.. However, when xpanes is executed in the existing tmux session, this socket file is not created. Instead, default tmux session file is used.

Ok, good to know but I am not in that case. I have just tried again the following:

xpanes --ssh serv1 serv2

Then ctrl+b d (dettach) and again, impossible to reattach them even if I see them:

ps fax | grep xpanes
1195 ?        Ss     0:00 tmux -S /home/faust/.cache/xpanes/socket.21113 new-session -s xpanes-21113 -n tmp-21113 -d /home/faust/Documents/.zplug/repos/greymd/tmux-xpanes/bin/xpanes '--ssh' '-c' 'ssh -o StrictHostKeyChecking=no {} '  '--' 'serv1' 'serv2'
greymd commented 4 years ago

Hi, @fauust

I have reproduced this phenomenon on my environment 👍 I think this behavior is better to be fixed.

I've just created the new issue to work on the issue. https://github.com/greymd/tmux-xpanes/issues/135

This issue will most likely be fixed in next version.

Workaround

The session file explicitly specified by -S is not deleted. Creating alias to avoid the behavior like this.

alias xpanes='xpanes -S /tmp/xpanes.$$'
fauust commented 4 years ago

Hi @greymd! Thanks for creating #135 and for the workaround!

Workaround tested and approved but I would suggest not creating those session files in /tmp as they could be critical on shared computers.

greymd commented 4 years ago

Fixed in v4.1.2