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

Update is_vim detection logic for tmux 3.2 #300

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ Add the following to your `~/.tmux.conf` file:
``` tmux
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_vim="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
Expand Down Expand Up @@ -289,3 +288,16 @@ script][] which has a more robust check.
[configuration section below]: #custom-key-bindings
[this blog post]: http://www.codeography.com/2013/06/19/navigating-vim-and-tmux-splits
[this gist]: https://gist.github.com/mislav/5189704

### Using The Plugin Freezes My Terminal

Starting from version 3.2 of tmux users were reporting that using the key
bindings to navigate panes would cause their terminal to freeze for 30+ seconds.
Thankfully @kidonchu was able to figure out a new version of the vim detection
script which also seems to be backwards compatible.

See [this issue](https://github.com/christoomey/vim-tmux-navigator/issues/299) for more
detail, but if you recent upgraded your tmux version and ran into the freezing
issue, you'll want to update to [the new `is_vim` snippet][].

[the new `is_vim` snippet]: https://github.com/christoomey/vim-tmux-navigator#add-a-snippet
3 changes: 1 addition & 2 deletions vim-tmux-navigator.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

version_pat='s/^tmux[^0-9]*([.0-9]+).*/\1/p'

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_vim="ps -o state=,tty=,comm= | grep -iqE '^[^TXZ ]+ +#{s|/dev/||:pane_tty}\s+(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
tmux bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
tmux bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
tmux bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
Expand Down