You are not logged in.

#1 2019-03-17 23:30:06

MrSauna
Member
Registered: 2019-03-17
Posts: 2

[SOLVED] .tmux.conf bind-key -n difficulties

I copied this popular vim-tmux config and tried to enhance it. My goal is to keep the functionality of the copied config and "fix" c-j c-k behavior in fzf or any specific open program. I want tmux to ignore c-j and c-k and pass them to the active pane. Currently it acts like my code isn't even there, vim/tmux part of this works like a charm.

# my code
is_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep fzf"
bind-key -n C-h if-shell "$is_fzf" "send-keys C-h" 
bind-key -n C-j if-shell "$is_fzf" "send-keys C-j" 
bind-key -n C-k if-shell "$is_fzf" "send-keys C-k" 
bind-key -n C-l if-shell "$is_fzf" "send-keys C-l" 

# 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)?$'"
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"
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"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l

# my code
set -s escape-time 0

Last edited by MrSauna (2019-03-18 12:40:51)

Offline

#2 2019-03-17 23:48:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,530
Website

Re: [SOLVED] .tmux.conf bind-key -n difficulties

Of course it acts like your code isn't there - as every single line you added is overwritten later.

You just need to add fzf to the grep pattern currently used for vim.

is_vim_or_fzf="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?|fzf)(diff)?$'"
bind-key -n C-h if-shell "$is_vim_or_fzf" "send-keys C-h"  "select-pane -L"
# ...

Last edited by Trilby (2019-03-17 23:49:49)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB