Open poetaman opened 3 years ago
I followed the repro steps and I can't reproduce the bug. However, I do believe you're getting a bug, but it's probably due to something else in your (and other users') environment.
I propose you try to figure it out. PR with a fix would be welcome!
@bruno- Are you setting any variable related to tmux-resurrect in tmux.conf file? I had just one, and commenting that also doesn't do anything different.
Perhaps you have more elaborate settings related to tmux-resurrect? Can you give it a try by disabling them if thats true? Btw, the bug is not reproducible if the process is started in right pane instead of left.
set -g @resurrect-processes ' \
"~nvim->nvim" \
'
Some system information:
OS: macOS 11.4 BigSur
Architecture: ARM-64
Terminal: iTerm2 or Alacritty
Shell zsh 5.8
Bash version: GNU bash, version 5.1.8(1)-release (aarch64-apple-darwin20.4.0)
Also, can you post your entire tmux.conf file? It would also help to understand the format of resurrect file. Like what's the line with -zsh (on line 2) (I guess that is the parent process).
@bruno- I debugged further, and this is what is happening:
Firstly, I am using the default save strategy, "ps". I am not sure what save strategy you are using?
The problem seems to stem from the following statement in file https://github.com/tmux-plugins/tmux-resurrect/blob/master/save_command_strategies/ps.sh
ps -ao "ppid command" |
sed "s/^ *//" |
grep "^${PANE_PID}" |
cut -d' ' -f2-
During first resurrect save it returns
htop
-zsh
After reloading resurrect session, and upon resurrect save again it returns:
-zsh
htop
The order is reversed, any thoughts of what this means?
@bruno- I think I fixed it! Adding a final piped grep to the ps
command grep -v -e "^-.*"
resolves the problem. It removed lines for login shell -zsh
.
ps -ao "ppid command" |
sed "s/^ *//" |
grep "^${PANE_PID}" |
cut -d' ' -f2- |
grep -v -e "^-.*"
Now every time the resurrect session file is saved like this:
pane 0 1 :zsh... 1 :* 1 :/Users/amanmehra 1 htop :htop
pane 0 1 :zsh... 1 :* 2 :/Users/amanmehra 0 zsh :
window 0 1 1 :* c920,300x76,0,0{150x76,0,0,1,149x76,151,0,2}
state 0
Please review, and let me know what you think. Then I will submit a PR.
Updated the command above from grep -v -e "-." to grep -v -e "^-.". Can be further refined to just catch login processes like
--zsh
,-bash
, etc.
This one was difficult to debug, but it's simple to reproduce.
Steps:
>>tmux kill-server
, and restart tmux>>tmux
.>>htop
or other program (I also triednvim
) in left pane.<prefix>Ctrl-s
.>>tmux kill-server
, and restart tmux>>tmux
.<prefix>Ctrl-r
. The session will restore correctly this time, withhtop
launched in left pane.<prefix>Ctrl-s
.>>tmux kill-server
, and restart tmux>>tmux
.<prefix>Ctrl-r
.This time
htop
won't launch automatically in left pane!I compared the files saved by tmux-resurrect in step 5, step 8. They are different, and the difference introduced is the cause of this bug. Here are the contents of the file
~/.tmux/resurrect/last
after step-5, and step-8:After step-5:
After step-8:
There seem to be two problems:
1) On first and second line, the programs htop & zsh got swapped.
2) On line four
2280
becamea281
, and145,0,1}
became145,0,2}
. Not sure what this is.There seem to be old bugs that complain about programs not launching correctly, in this one I give simple steps to reproduce & source of the problem. Hopefully this will get resolved sooner than later :) it will make tmux-resurrect reliable!