Permalink
Browse files

Add support for installing via Tmux Plugin Manager

  • Loading branch information...
1 parent 293ef22 commit d5dc8d3c80cf898a25b8cf16ab65cf6a5438009f @raviqqe raviqqe committed with Apr 30, 2016
Showing with 27 additions and 3 deletions.
  1. +18 −3 README.md
  2. +9 −0 vim-tmux-navigator.tmux
View
@@ -47,10 +47,13 @@ Then run
:PluginInstall
```
-### Tmux
+### tmux
-Add the following to your `tmux.conf` file to configure the tmux side of
-this customization.
+To configure the tmux side of this customization there are three options:
+
+#### Add a snippet
+
+Add the following to your `~/.tmux.conf` file:
``` tmux
# Smart pane switching with awareness of Vim splits.
@@ -64,6 +67,17 @@ bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
```
+#### TPM
+
+If you'd prefer, you can use the Tmux Plugin Manager ([TPM][]) instead of
+copying the snippet.
+When using TPM, add the following lines to your ~/.tmux.conf:
+
+``` tmux
+set -g @plugin 'christoomey/vim-tmux-navigator'
+run '~/.tmux/plugins/tpm/tpm'
+```
+
Thanks to Christopher Sexton who provided the updated tmux configuration in
[this blog post][].
@@ -236,6 +250,7 @@ script][] which has a more robust check.
[Mislav Marohnić's]: http://mislav.uniqpath.com/
[Mislav's original external script]: https://github.com/mislav/dotfiles/blob/master/bin/tmux-vim-select-pane
[Vundle]: https://github.com/gmarik/vundle
+[TPM]: https://github.com/tmux-plugins/tpm
[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
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
+ | grep -iqE '^[^TXZ ]+ +(\\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"
+tmux bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
+tmux bind-key -n C-\\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"

0 comments on commit d5dc8d3

Please sign in to comment.