tmux-plugins / tmux-resurrect

Persists tmux environment across system restarts.
MIT License
11.29k stars 421 forks source link

Restore not starting processes #129

Open codisms opened 8 years ago

codisms commented 8 years ago

When doing prefix C-r, the windows and panes open correctly, and pane contents are there, but the commands aren't restarted, even though I spelled out that I want "tail" in the @resurrect-processes option.

I use zsh as my shell, if that matters.

.tmux.conf (removed key bindings):

#set status-utf8 on
#set utf8 on

set -g default-terminal "screen-256color"

source-file ~/.codisms/repos/solarized/tmux/tmuxcolors-256.conf

#set -g default-command "reattach-to-user-namespace -l $SHELL"

# plugin settings
set -g @resurrect-capture-pane-contents 'on'
set -g @continuum-save-interval '15'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-processes 'vim man less tail more htop top mutt elinks'

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

run '~/.tmux/plugins/tpm/tpm'

Latest stored state:

pane    default 1   :editor 0   :   1   :/root/Veritone/node/datacenter 1   zsh :
pane    default 1   :editor 0   :   2   :/root/Veritone/node/core-recording-server  0   vim :vim /root/.ssh/config
pane    default 1   :editor 0   :   3   :/root/.codisms/bin 0   zsh :
pane    default 1   :editor 0   :   4   :/root/go/src/github.com/veritone/youtube-ripper    0   zsh :
pane    default 2   :db 0   :   1   :/root  1   vim :vim -S /root/.codisms/vim/vimrc.db
pane    default 3   :po 0   :-  1   :/root/Thotspots/Payoff 0   top :top
pane    default 3   :po 0   :-  2   :/root/Thotspots/Payoff/savings_rails_demo/app/assets/templates 0   htop    :htop
pane    default 3   :po 0   :-  3   :/root/Thotspots/Payoff/savings_rails_demo/log  0   tail    :tail -f development.log
pane    default 3   :po 0   :-  4   :/root/Thotspots/Payoff/savings_api/log 0   tail    :tail -f development.log
pane    default 3   :po 0   :-  5   :/root/Thotspots/Payoff/savings_jobs/log    1   tail    :tail -f development.log
pane    default 4   :setup  0   :   1   :/root/.setup/linux 0   zsh :
pane    default 4   :setup  0   :   2   :/etc/systemd/system    0   zsh :
pane    default 4   :setup  0   :   3   :/var/log   1   zsh :
pane    default 5   :zsh    1   :*  1   :/root/.codisms/tmux/resurrect  1   zsh :
window  default 1   0   :   0f69,171x48,0,0{85x48,0,0,2,85x48,86,0[85x13,86,0,3,85x17,86,14,4,85x16,86,32,5]}
window  default 2   0   :   ccc3,171x48,0,0,6
window  default 3   0   :-  5050,171x48,0,0{85x48,0,0[85x22,0,0,7,85x25,0,23,8],85x48,86,0[85x16,86,0,9,85x16,86,17,10,85x14,86,34,11]}
window  default 4   0   :   e6a1,171x48,0,0[171x24,0,0,12,171x23,0,25{85x23,0,25,13,85x23,86,25,14}]
window  default 5   1   :*  6697,171x48,0,0,18
state   default

default-command:

[~] » tmux show -g default-command
default-command ""
codisms commented 8 years ago

In adding debug statements to restore.sh, it seems like it's picking up that the processes should be restored, but the tmux send-keys command isn't working.

bruno- commented 8 years ago

Interesting, we never had this issue before.

Is tmux send-keys not working at all? What happens if you manually execute tmux send-keys "foo bar" in the terminal?

codisms commented 8 years ago

Works just fine.

[~] » tmux send-keys "wee"
wee#                                                                                                                                                                       [~] » wee
codisms commented 8 years ago

I found a fix. If I specify the entire session/window/pane on the command line, like so: tmux send-keys -t "${session_name}:${window_number}.$pane_index"

sixshotx commented 8 years ago

I have similar problem here under zsh. I tried "htop" and "vim" on reboot, yet neither command is restored. The operating system is arch linux, and default-command is "".

moonrumble commented 7 years ago

I am also having the same issue ssh process is not starting.

SomeoneSerge commented 7 years ago

Probably I encountered the same problem. prefix C-r switches to created pane but sends all the commands to the executing one (i.e. the pane, from which I've sent prefix C-r). Explicitly specifying -t $session_name:$window_number.pane_index works just fine.

Here's tmux show -g output. I'm using tmux 2.3 from archlinux repositories. Shell is zsh.


Is it ever supposed to work? pty1:

$ tmux new -s mains -n mainw

pty2:

$ cat > test.sh <<EOF
tmux switch-client -t mains:mainw
tmux select-pane -t 0
tmux send-keys sup
EOF
$ chmod +x test.sh
$ tmux new -s runner

pty3:

$ tmux new -t runner
$ ./test.sh

For me, the results are:

Apparently, tmux-resurrect expects that "sup" will be in pty1

tom-i commented 7 years ago

Hi all, I have same issue as described here. Looks that main problem is that we're using ZSH against Bash. My windows and panes have been restored too, but no Vim session, htop, man and ranger (I put it to my tmux.conf) tmux_tom.zip

Is there any solution for this? Thx for reply.

Tom

EDIT: When I've changed default shell to BASH from ZSH, it works without problem (expect ranger), so Vim, man, htop have been restored.

GCorbel commented 7 years ago

I have the same issue. Is there a solution?

christarazi commented 7 years ago

I have the same issue as well. Any updates for zsh users?

Edit: I can confirm @codisms' temporary fix works for now.

emmanuelgeoffray commented 7 years ago

Hi have the same issue with arch/zsh. @christarazi @codisms how do you use tmux send-keys -t "${session_name}:${window_number}.$pane_index" ? Do you actually type that to run tmux? Or after tmux is running? Do you rplace ${...} with values?

emmanuelgeoffray commented 7 years ago

OK, I found out that by updating tmux-resurrect/scripts/process_restore_helpers.sh with tmux send-keys -t "${session_name}:${window_number}.$pane_index" like below, it works again. Should I do a pull request?

 10 restore_pane_process() {
 11   local pane_full_command="$1"
 12   local session_name="$2"
 13   local window_number="$3"
 14   local pane_index="$4"
 15   local dir="$5"
 16   if _process_should_be_restored "$pane_full_command" "$session_name" "$window_number" "$pane_index"; then
 17     tmux switch-client -t "${session_name}:${window_number}"
 18     tmux select-pane -t "$pane_index"
 19     local pane_id="${session_name}:${window_number}.$pane_index"
 20 
 21     local inline_strategy="$(_get_inline_strategy "$pane_full_command")" # might not be defined
 22     if [ -n "$inline_strategy" ]; then
 23       # inline strategy exists
 24       tmux send-keys -t "$pane_id" "$inline_strategy" "C-m"
 25     elif _strategy_exists "$pane_full_command"; then
 26       local strategy_file="$(_get_strategy_file "$pane_full_command")"
 27       local strategy_command="$($strategy_file "$pane_full_command" "$dir")"
 28       tmux send-keys -t "$pane_id" "$strategy_command" "C-m"
 29     else
 30       # just invoke the command
 31       tmux send-keys -t "$pane_id" "$pane_full_command" "C-m"
 32     fi
 33   fi
 34 }
GCorbel commented 7 years ago

@emmanuelgeoffray yes, I thin a PR can be useful. I'm interested by your work.

Thanks !

emmanuelgeoffray commented 7 years ago

hey @GCorbel ! After more tests, I have an inutition that the issue comes from session with no names, just numbers. Can you try tthis? start a new session with a name: tmux new -s mysession open a few panes, vim some files, close all other sessions prefix :kill-session -a save this session : prefix C-s kill session: prefix :kill-session run tmux again tmux restore session: prefix C-r

Does it work?

GCorbel commented 7 years ago

@emmanuelgeoffray it doesn't works. Vim is not restored properly an all program are stooped.

GCorbel commented 7 years ago

Good news, your code seems to work. Thanks for that.

christarazi commented 7 years ago

@emmanuelgeoffray A pull request doesn't seem necessary, #180 already exists and fixes the problem. Not sure what the maintainers think of it.

emmanuelgeoffray commented 7 years ago

Great! Thanks for pointing that out @christarazi

ahartz1 commented 7 years ago

I was having this problem, too, and the change that @emmanuelgeoffray shared above (and that mk12 implemented in #180) fixed it for me.