0

I use this tmux-configuration based on the post from bartj3 in [1].

bind j split-window -v "tmux list-sessions -F '#S' | fzf --reverse | xargs tmux switch-client -t"
bind k split-window -v "tmux list-window -F '#W' | fzf --reverse | xargs tmux select-window -t"

It let's you interactively (search-as-you-type) search for other sessions and windows by name and therefore switch between them more efficiently.

PROBLEM:

If you use the above while synchronize-panes is on, your search key-strokes will also type in the other (non-search-)panes.

QUESTION:

Does anyone have an idea on how to limit the key-strokes to the search-pane?

[1] Interactive search of tmux sessions

1 Answer 1

1

You can save the current state of synchronize-panes before calling fzf, and then restore it to on afterwards if necessary. For example, this works for me, using bash as the default shell:

bind-key k split-window -v '\
 if [[ $(tmux show-window-option synchronize-panes) == *on ]];\
 then tmux set-window-option -q synchronize-panes off;\
     restore="tmux set-window-option -q synchronize-panes on";\
 fi;\
 tmux list-windows -F "#W" | fzf --reverse | xargs tmux select-window -t;\
 $restore'

Since this is a long shell command, it can be split over many lines provided they each end with a backslash, and shell semi-colons (;) are used as if it was all on one line. You might prefer to put this as a shell script in a file in your PATH and call it instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .