Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Seamless window, pane switching in vim inside tmux

  • Loading branch information...
commit 1a0c1aaea2a1cf05290b290faf0644d54e64975b 1 parent e73e515
Wynn Netherland authored
17 bin/tmux-vim-select-pane
... ... @@ -0,0 +1,17 @@
  1 +#!/usr/bin/env bash
  2 +# Like `tmux select-pane`, but if Vim is running in the current pane it sends a
  3 +# keystroke to Vim instead to let it decide whether it's going to switch windows
  4 +# internally or switch tmux panes.
  5 +set -e
  6 +
  7 +# gets the tty of active tmux pane
  8 +active_tty="$(tmux list-panes -F '#{pane_active}#{pane_tty}' | grep '^1')"
  9 +
  10 +# checks if there's a foreground Vim process in attached to that tty
  11 +if ps c -o 'state=,command=' -t "${active_tty#1}" | grep '+' | grep -iE '\bvim?\b' >/dev/null ; then
  12 + direction="$(echo "${1#-}" | tr 'lLDUR' '\\hjkl')"
  13 + # forward the keystroke to Vim
  14 + tmux send-keys C-$direction
  15 +else
  16 + tmux select-pane "$@"
  17 +fi
12 tmux/tmux.conf.symlink
@@ -20,7 +20,7 @@ bind-key C-a last-window
@@ -34,10 +34,12 @@ bind-key , previous-window # <
30 vim/vim.symlink/tmux.vim
... ... @@ -0,0 +1,30 @@
1  vim/vimrc.symlink
@@ -11,6 +11,7 @@ source ~/.vim/autocmd.vim

0 comments on commit 1a0c1aa

Mislav Marohnić

Why commented this out? C-\ shouldn't interfere with it I think

Wynn Netherland

Ha, yeah, adding that back, it works fine. I was debugging my application of your gist before I realized I hadn't reloaded tmux.conf. facepalm

Please sign in to comment.
Something went wrong with that request. Please try again.