Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FocusGained works with Terminal.app (and tmux) #28

Open
bruno- opened this issue Dec 13, 2014 · 5 comments
Open

FocusGained works with Terminal.app (and tmux) #28

bruno- opened this issue Dec 13, 2014 · 5 comments

Comments

@bruno-
Copy link

bruno- commented Dec 13, 2014

Hi,
it seems I managed to get FocusGained work by using this plugin and tmux. Steps for this are below and I'm still a bit fuzzy *why* this works.

Tools:

  • OS X 10.10.1, Terminal.app (iTerm will work just fine, but we already knew it works)
  • tmux 1.9a
  • terminal vim (neovim works too)

How to enable FocusGained for terminal vim with the above tools:

  • make sure tmux has the focus-events option on: tmux set -g focus-events on
  • install the vitality.vim plugin
  • set this option: let g:vitality_always_assume_iterm = 1

That's it! FocusGained should now work. I've tested it with vim by setting the following autocommand:

au FocusGained * echom 'focus gained!'

A couple observations:

  • FocusLost does not work for some reason
  • this does not work outside tmux (plain Terminal.app + vim)

If this plugin is still maintained, do you think we could add these instructions somewhere (wiki maybe) so people know this is possible? Also, how about enabling the plugin when vim is running inside tmux so that let g:vitality_always_assume_iterm = 1 is not required?

@bruno- bruno- mentioned this issue Dec 13, 2014
@chrischoy
Copy link

Thanks,

Confirmed correct actions (FocusGain, FocusLost) on Terminal.app, OS 10.10

When you changed the .tmux.conf, make sure to reload or kill the tmux server. This caused me an hour to debug.

Unlike @bruno-, FocusLost also works seamlessly.

@unphased
Copy link

unphased commented Mar 1, 2015

@bruno- @chrischoy My experience has been that FocusLost pretty much works, except that no matter what I tried I could not make it properly run echo or echom (while FocusGained had no problems with it). It is bizarre, but I am not about to lose sleep over it.

@bruno-
Copy link
Author

bruno- commented Mar 3, 2015

Hey, it's good to hear that FocusLost works for you guys.. btw. how were you able to verify it works if echo or echom doesn't work?

I just tried and this au FocusLost * echom 'focus lost!' doesn't work for me too.

@unphased
Copy link

unphased commented Mar 3, 2015

au FocusLost * stopinsert

@bruno-
Copy link
Author

bruno- commented Mar 3, 2015

Thanks for sharing.. that one works!

On Tue, Mar 3, 2015 at 2:59 PM, Steven Lu notifications@github.com wrote:

au FocusLost * stopinsert


Reply to this email directly or view it on GitHub
#28 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants