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

Detect vim pane using more portable ps command. #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,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 -a |grep -qE '.*''#{s|/dev/||:pane_tty}'' .*+(\\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 @@ -219,15 +218,8 @@ altered to avoid conflicting with the mappings from the plugin.

Another option is that the pattern matching included in the `.tmux.conf` is
not recognizing that Vim is active. To check that tmux is properly recognizing
Vim, use the provided Vim command `:TmuxNavigatorProcessList`. The output of
that command should be a list like:

```
Ss -zsh
S+ vim
S+ tmux
```

Vim is running in a tmux pane, use the provided Vim command `:TmuxNavigatorProcessList`. The output of
that command should look like the output from `ps -a|grep vim`.
If you encounter a different output please [open an issue][] with as much info
about your OS, Vim version, and tmux version as possible.

Expand Down
2 changes: 1 addition & 1 deletion plugin/tmux_navigator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function! s:TmuxCommand(args)
endfunction

function! s:TmuxNavigatorProcessList()
echo s:TmuxCommand("run-shell 'ps -o state= -o comm= -t ''''#{pane_tty}'''''")
echo s:TmuxCommand("run-shell 'ps -a|grep -E \"''''#{s|/dev/||:pane_tty}'''' .*+(\\S+\\/)?g?(view|n?vim?x?)(diff)?$\"'")
endfunction
command! TmuxNavigatorProcessList call s:TmuxNavigatorProcessList()

Expand Down
3 changes: 1 addition & 2 deletions vim-tmux-navigator.tmux
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env bash

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
is_vim="ps -a |grep -qE '.*''#{s|/dev/||:pane_tty}'' .*+(\\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