Skip to content

Instantly share code, notes, and snippets.

@thugcee
Created January 11, 2021 22:56
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
tmux and fzf: fuzzy tmux session/window/pane switcher (this version uses tmux new popup window)
#!/bin/bash
# customizable
LIST_DATA="#{window_name} #{pane_title} #{pane_current_path} #{pane_current_command}"
FZF_COMMAND="fzf-tmux -p --delimiter=: --with-nth 4 --color=hl:2"
# do not change
TARGET_SPEC="#{session_name}:#{window_id}:#{pane_id}:"
# select pane
LINE=$(tmux list-panes -a -F "$TARGET_SPEC $LIST_DATA" | $FZF_COMMAND) || exit 0
# split the result
args=(${LINE//:/ })
# activate session/window/pane
tmux select-pane -t ${args[2]} && tmux select-window -t ${args[1]} && tmux switch-client -t ${args[0]}
bind-key ` run-shell -b tmux-switch-pane.sh
@vnea
Copy link

vnea commented Nov 25, 2021

Very nice script :D.

@howarddo2208
Copy link

very nice, thank u! Can you add preview to this too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment