Can't move from vim to tmux with fish as shell #148

scolby33 opened this Issue Aug 31, 2016 · 8 comments


None yet

2 participants


I am having a similar issue as #141, but in my case :TmuxPaneCurrentCommand does output vim. Otherwise, the plugin and configuration work perfectly: movement between vim splits, movement between tmux panes, and movement from tmux panes to vim.

I know it is not the key bindings; running :TmuxNavigate{Up|Left|Down|Right} manually moves between vim splits successfully but will not move out of vim into tmux.

OS X 10.11.6
Vim 7.4
tmux 2.2
iTerm2 3.0.7


@scolby33 sorry to hear about the trouble. Based on the fact that you can move within splits, I don't believe the Vim detection is the problem. Instead, it sounds like the Vim plugin code is not properly detecting when you're at the wall. Can you describe what happens when you attempt to navigate from Vim to tmux? Is it nothing, or do you move to a different Vim split?

Also, would you mind running with just the plugin active (no vimrc) using the following command:

vim -U NONE -c 'source ~/.vim/bundle/tmux-navigator/plugin/tmux_navigator.vim'

If I am already at the "edge" of vim and attempt to navigate out to tmux, nothing happens.

Running with just the plugin active did not solve the issue.

However, I am using fish as my shell. Adding the following snippet to my .vimrc fixed the issue:

if &shell =~# 'fish$'
    set shell=sh

This is a bit surprising because (in only a cursory look, admittedly), I don't see why the plugin's attempts to call out to the shell would be hindered by fish vs. bash or sh...the tmux commands are the same for all.


Depending on the version of the plugin you're using, we might have introduced an env variable into the system call that could be the issue. Can you try running :echo $TMUX_PANE with fish as your shell to confirm?


With fish as the shell, this returns %1. The same result occurs when forcing the shell to be sh as well.

I am using the most recent plugin version installed by Vundle.


Can you try running the following?

  1. Tmux window with Vim on the left, tmux pane on the right
  2. In Vim, run :echo system('tmux select-pane -t '. $TMUX_PANE .' -R') and capture anything that is echoed
  3. Check the output (again in Vim) of :echo v:shell_error.
scolby33 commented Sep 1, 2016 edited

With the sh workaround in .vimrc, nothing was echoed in step (2) and the tmux pane was switched. Step (3) returned 0.

Without the workaround, again nothing was echoed in step (2) and the tmux pane was not switched. Step (3) returned 0 again.

Just running :! tmux select-pane -t $TMUX_PANE -R in the vim command line works correctly in both cases.


Hmm, well unfortunately I'm out of ideas. Feel free to poke around and share back if you are able to track anything down. Sorry I couldn't be of more help.

scolby33 commented Sep 2, 2016

I figured it out! Here are my observations:

  1. The command you gave earlier to run just the plugin should be vim -u NONE -c 'set nocompatible' -c 'source ~/.vim/bundle/tmux-navigator/plugin/tmux_navigator.vim' Note the lower-case -u and the addition of set nocompatible. Without nocompatible set, the plugin bails out when checking &cp right at the start.
  2. fish uses % for process expansion, so the composed command like tmux -S whatever select-pane -t %1 -D fails. Unfortunately, fish doesn't return an error code when this happens, it just prints an error message. (I'm not even sure if it's to stderr or what, but that doesn't end up mattering.)

Running tmux -S whatever select-pane -t \%1 -D works correctly in fish and bash at first glance, but I can't claim to have tested thoroughly.

I will make a pull request momentarily with my suggested change.

@scolby33 scolby33 changed the title from Can't move from vim to tmux to Can't move from vim to tmux with fish as shell Sep 2, 2016
@blueyed blueyed closed this in e79d4c0 Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment