tmux-plugins / tmux-sensible

basic tmux settings everyone can agree on
MIT License
1.79k stars 92 forks source link

`focus-events on` is messy with fish shell #20

Open bruno- opened 9 years ago

bruno- commented 9 years ago

Issue from stack overflow: http://stackoverflow.com/questions/28039788/window-focus-adds-characters-to-shell

baroldgene commented 9 years ago

Curious.....is there any reason not to turn off focus_events when exiting tmux for everyone regardless of shell?

baroldgene commented 9 years ago

Also, I'm somewhat new to tmux. Is there a way to perform tasks or set configuration options either A) based on terminal or B) on detach?

bruno- commented 9 years ago

Hey thanks for checking this issue out.

is there any reason not to turn off focus_events when exiting tmux for everyone regardless of shell?

Hm.. I'm not sure I understand this.. I thought focus events (the special sequence of charaters like ^[O[I you described in a SO question) is generated by tmux on certain events like switching windows or panes. So if that theory is right, the events should be automatically off when tmux is detached or killed.

bruno- commented 9 years ago

I checked tmux source (not that I understand it, or even know C language for that matter), but it seems the "theory" from the above post might be true. Here's the link to relevant lines in tmux source. So it seems tmux is first doing some checks and then sends the \033[O or \033[I to panes..

So yea, long story short, at first sight I'd say pane events should not happen outside tmux. Are you seing something else when using fish shell?

Also, I'm somewhat new to tmux. Is there a way to perform tasks or set configuration options either A) based on terminal or B) on detach?

I'm not sure you could do this in your .tmux.conf as it only understands tmux's options, but A) should definitely be possible in tmux-sensible.

bruno- commented 9 years ago

Update: I keep accidentally posting messages before I finish them.. sorry for the noise.

You should be able to check which terminal is tmux running in tmux sensible file by just testing the $SHELL environment variable. Something like this [[ "$SHELL" =~ fish$ ]]

baroldgene commented 9 years ago

So yea, long story short, at first sight I'd say pane events should not happen outside tmux. Are you seeing something else when using fish shell?

Yeah. The issue is that I start tmux, then either exit or disconnect and the focus events being sent show up on the prompt since tmux is no longer there listening for them.

It's entirely possible that these same keystrokes are being sent to bash and just ignored.

I'd say this seems more like a tmux issue than a tmux-sensible one.

bruno- commented 9 years ago

I'd say this seems more like a tmux issue than a tmux-sensible one.

Yea. And that would explain it why the focus-events is "off" by default. Also, let's not discard the possibility of this being a 'fish' shell issue or a thing they need to add.

My knowledge on this is fuzzy, but I think these events are somewhat standardized to these codes ^[[O and ^[[I. From what I know, vim can understand those, iTerm application on OSX "sends" the codes as well as terminal applications on Linux. So maybe it's fish that's lagging to implement support for it?

baroldgene commented 9 years ago

That's a very good point.

baroldgene commented 9 years ago

I opened this ticket with the fish shell dev team: https://github.com/fish-shell/fish-shell/issues/1917

I'm interested to see where the discussion goes and if the fish devs agree that it should be solved there.

bruno- commented 9 years ago

It seems fish maintainers opened an issue to tmux core and the fix was found: http://sourceforge.net/p/tmux/tickets/176/

Good to see things getting better. Thanks for taking the time to investigate and report this in the first place @baroldgene.

baroldgene commented 9 years ago

Thanks for helping me track this one down! :+1: