• Stars
    star
    348
  • Rank 121,840 (Top 3 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make terminal vim and tmux work better together.

tmux-focus-events.vim

Update: this plugin is now obsolete and no longer needed as both neovim and vim (since version 8.2.2345) have native support for this functionality.

FocusGained and FocusLost autocommand events are not working in terminal vim. This plugin restores them when using vim inside Tmux.

Here's where that matters:

  • vim-fugitive plugin uses FocusGained for refreshing git branch in status line
  • vim-gitgutter uses FocusGained for refreshing ... (wait for it) git gutter
  • vim-tmux-clipboard uses FocusGained and FocusLost for refreshing clipboard.
  • (get in touch if you know other popular plugins that get improved)

Also, vim-tmux-focus-events makes the autoread option work properly for terminal vim. So far, this was only working in a GUI version.

The autoread feature comes handy when files are changed outside vim, for example when resolving merge conflicts. When you come back to vim and try saving a changed file you'll likely be interrupted with E813:

vim E813

Improved autoread prevents this by automatically reading a file from disk if it was changed. Works only if autoread option is set (enable it with set autoread in .vimrc).

Installation & Configuration

Vim plugin installation

  • Vundle
    Plugin 'tmux-plugins/vim-tmux-focus-events'

  • vim-plug
    Plug 'tmux-plugins/vim-tmux-focus-events'

  • Pathogen
    git clone git://github.com/tmux-plugins/vim-tmux-focus-events.git ~/.vim/bundle/vim-tmux-focus-events

Tmux configuration

In order for Tmux to do its magic focus-events option has to be set to on.

Enable that by installing tmux-sensible plugin, or by setting this line in tmux.conf:

set -g focus-events on

Testing

Tested and working on:

  • OS X

    • Terminal.app
    • iTerm2
  • Linux

    • GNOME Terminal
    • Terminator
    • XTerm
    • Konsole
    • st

Usage

Once installed, the plugin should "just work".

It will have no effect when running GUI vim or inside plain terminal (without Tmux).

Other goodies

Credits

Big chunk of code was taken and adapted from vitality.vim.

Other

In April 2013 a patch was submitted to vim_dev mailing list that enables this functionality natively in vim. Once merged, the functionality from the patch will make this plugin obsolete. I hope that day comes soon.

Licence

MIT

More Repositories

1

tpm

Tmux Plugin Manager
Shell
12,082
star
2

tmux-resurrect

Persists tmux environment across system restarts.
Shell
11,249
star
3

tmux-continuum

Continuous saving of tmux environment. Automatic restore when tmux is started. Automatic tmux start when computer is turned on.
Shell
3,263
star
4

tmux-yank

Tmux plugin for copying to system clipboard. Works on OSX, Linux and Cygwin.
Shell
2,682
star
5

tmux-sensible

basic tmux settings everyone can agree on
Shell
1,756
star
6

list

A list of tmux plugins.
1,201
star
7

tmux-copycat

A plugin that enhances tmux search
Shell
1,103
star
8

tmux-logging

Easy logging and screen capturing for Tmux.
Shell
1,034
star
9

tmux-pain-control

standard pane key-bindings for tmux
Shell
755
star
10

tmux-open

Tmux key bindings for quick opening of a highlighted file or url
Shell
631
star
11

tmux-prefix-highlight

Plugin that highlights when you press tmux prefix key
Shell
571
star
12

tmux-sidebar

A sidebar with the directory tree for the current path. Tries to make tmux more IDE like.
Shell
536
star
13

tmux-battery

Plug and play battery percentage and icon indicator for Tmux.
Shell
499
star
14

tmux-cpu

Plug and play cpu percentage and icon indicator for Tmux.
Shell
433
star
15

tmux-sessionist

Lightweight tmux utils for manipulating sessions
Shell
412
star
16

vim-tmux

vim plugin for tmux.conf
Vim Script
333
star
17

tmux-fpp

Quickly open any path on your terminal window in your $EDITOR of choice!
Shell
308
star
18

tmux-urlview

Quickly open any url on your terminal window!
Shell
266
star
19

tmux-online-status

Tmux plugin that displays online status of your computer.
Shell
169
star
20

tmux-example-plugin

Example Tmux plugin that actually demonstrates how to build plugins for Tmux. The accompanying tutorial is here: https://github.com/tmux-plugins/tpm/blob/master/HOW_TO_PLUGIN.md
Shell
45
star
21

tmux-cowboy

Kill hanging processes fast
Shell
37
star
22

tmux-maildir-counter

Plugin that counts files on a specific mail directory
Shell
32
star
23

tmux-test

A small framework for isolated testing of tmux plugins.
Shell
16
star
24

language-tmux

Atom language support for Tmux config file
CoffeeScript
10
star
25

tmux-newsboat

Display newsboat counters in tmux status line.
Shell
10
star