greymd / tmux-xpanes

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

MacOS: Command with long arguments stops in the middle of send-keys. #109

Closed aero closed 5 years ago

aero commented 5 years ago

Environment: MacOS 10.14.3(Mojave), tmux 2.8

My test command with long arguments.

$ xpanes --debug -s -c 'ping {}' host{1..60}.domain.com

but it stops in the middle of send-keys. I have no problem on linux.

$ /usr/local/bin/xpanes '--debug' '-s' '-c' 'ping {}' '--' 'host1.domain.com' 'host2.domain.com' 'host3.domain.com' 'host4.domain.com' 'host5.domain.com' 'host6.domain.com' 'host7.domain.com' 'host8.domain.com' 'host9.domain.com' 'host10.domain.com' 'host11.domain.com' 'host12.domain.com' 'host13.domain.com' 'host14.domain.com' 'host15.domain.com' 'host16.domain.com' 'host17.domain.com' 'host18.domain.com' 'host19.domain.com' 'host20.domain.com' 'host21.domain.com' 'host22.domain.com' 'host23.domain.com' 'host24.domain.com' 'host25.domain.com' 'host26.domain.com' 'host27.domain.com' 'host28.domain.com' 'host29.domain.com' 'host30.domain.com' 'host31.domain.com' 'host32.domain.com' 'host33.domain.com' 'host34.domain.com' 'host35.domain.com' 'host36.domain.com' 'host37.domain.com' 'host38.domain.com' 'host39.domain.com' 'host40.domain.com' 'host41.domain.com' 'host42.domain.com' 'host43.domain.com' 'host44.domain.com' 'host45.domain.com' 'host46.domain.com' 'host47.domain.com' 'host48.domain.com' 'host49.domain.<-- stops here.

greymd commented 5 years ago

Hi @aero !

Hmm ... I cannot reproduce it on my macOS with iTerm2 and tmux 2.8. It seems that you run this command on the normal terminal (outside of tmux session), don't you ?

What's happened if you run it on the tmux session? What terminal software are you using ?

aero commented 5 years ago

@greymd

Hmm ... I cannot reproduce it on my macOS with iTerm2 and tmux 2.8. It seems that you run this command on the normal terminal (outside of tmux session), don't you ?

Yes, I had run on the normal terminal both on linux and MacOS.

What's happened if you run it on the tmux session? What terminal software are you using ?

Within tmux session, I have no problem. Why does tmux's send-keys stop in vanilla MacOS's ITerm2 session ?

greymd commented 5 years ago

I could re-produce the same issue with following configures.

Thank you for let me know it! As you said, the sent text given by send-keys is defective.

/usr/local/bin/xpanes '--debug' '-s' '-c' 'ping {}'  '--' 'host1.domain.com' 'host2.domain.com' 'host3.domain.com' 'host4.domain.com' 'host5.domain.com' 'host6.domain.com' 'host7.domain.com' 'host8.domain.com' 'host9.domain.com' 'host10.domain.com' 'host11.domain.com' 'host12.domain.com' 'host13.domain.com' 'host14.domain.com' 'host15.domain.com' 'host16.domain.com' 'host17.domain.com' 'host18.domain.com' 'host19.domain.com' 'host20.domain.com' 'host21.domain.com' 'host22.domain.com' 'host23.domain.com' 'host24.domain.com' 'host25.domain.com' 'host26.domain.com' 'host27.domain.com' 'host28.domain.com' 'host29.domain.com' 'host30.domain.com' 'host31.domain.com' 'host32.domain.com' 'host33.domain.com' 'host34.domain.com' 'host35.domain.com' 'host36.domain.com' 'host37.domain.com' 'host38.domain.com' 'host39.domain.com' 'host40.domain.com' 'host41.domain.com' 'host42.domain.com' 'host43.domain.com' 'host44.domain.com' 'host45.domain.com' 'host46.domain.com' 'host47.domain.com' 'host48.domain.com' 'host49.domain.

Let me check it further more.

greymd commented 5 years ago

This issue can be produced without xpanes ( see later ). This is most likely due to the bug given by the tmux built on the macOS.

For now, the workaround is start the xpanes on the running tmux session (xpanes does not call send-keys when the tmux session is ongoing). But, let me check further. I may find another workaround. I believe xpanes can run without send-keys even if it's on the outside of tmux session.

Result of investigation

In my environment

  1. open new tmux session
  2. Run this command on the tmux session
$ tmux send-keys "$(yes | head -n 1024 | tr -d '\n')" C-m

=> same issue

$ tmux send-keys "$(yes | head -n 1023 | tr -d '\n')" C-m

=> the issue is not produced and error message of the shell is displayed

zsh: file name too long: yyy....
bash: yy...yy : command not found

I noticed following conditions

greymd commented 5 years ago

This issue is going to be fixed next version v3.1.1. new-session is used instead of send-keys. This way is more efficient.

https://github.com/greymd/tmux-xpanes/commit/9df78a856e34d420fb2d0acc720227c5e825ca80

greymd commented 5 years ago

v3.1.1 is released and this issue is resolved. If it continues, please reopen it. Thanks!