0

For some reason Tmux is showing zsh when it should be showing vim for the output of #{pane_current_command}, this is screwing up my vim aware pane moving commands in tmux which rely on it working correctly:

# vim aware commands
# pane/split switching
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" #left
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" #down
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" #up
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" #right
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" #next
# pane/split creation
bind | run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w && tmux send-keys v) || tmux split-window -h" #verticle
bind - run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w && tmux send-keys s) || tmux split-window -v" #horizontal
# pane/split close
bind x run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-w && tmux send-keys q) || tmux kill-pane "

I'm starting vim via an alias:

alias vim='rbenv only -r 2.3.5 -c "/usr/local/bin/vim" $@'

it is indeed the alias the causing the issue, How do I fix this, is there any way to set the name of the current process?

I found jobs -Z but that doesn't seem to work for an alias.

  • Not sure it can help, but I had a similar problem with mutt a few days ago, and posted about it here. – Rastapopoulos Oct 20 '17 at 11:51
  • I'm just guessing but I imagine tmux just looks up the immediate child process with ps or by looking at /proc files (in your case the child is zsh and vim is a "grandchild" process) and there's nothing you'll be able to do to change that short of hacking tmux code (or, in this example, invoking vim directly, not through intermediate shell). Or write/find code that let's you customize process name from the process (I know it's possible) and wrap your zsh/vim invocation in that. (!!) – B Layer Oct 20 '17 at 15:01
  • 1
    BTW, I'm assuming rbenv launches a subshell within which your command runs. That would explain the behavior you're seeing. Things might be better if instead it did exec. – B Layer Oct 20 '17 at 15:12
  • Yeah, I think that's pretty much it as well, any idea on how to fix this? – Thermatix Oct 23 '17 at 7:27
1

Ok, so after seeing the comment left by @B-Layer I created a simple bash function to replace the alias I was using that allows me to have my cake and eat it!

The function:

function vim()
{
    cmd="exec /usr/local/bin/vim $@"
    rbenv only -r $GLOBAL_RUB_VERSION -c "$cmd";
}

Now it allows me to start vim using rbenv only so it always starts with the same version of ruby that vim was compiled against. Now (the reason for this song and dance) YouCompleteMe won't ever complain/crash because I switched ruby versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.