Skip to content

Instantly share code, notes, and snippets.

@thugcee
Created January 11, 2021 22:56
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save thugcee/41d1ba786fa5e66167ed6ee45e4f6346 to your computer and use it in GitHub Desktop.
Save thugcee/41d1ba786fa5e66167ed6ee45e4f6346 to your computer and use it in GitHub Desktop.
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?

@nalakawula
Copy link

nalakawula commented Feb 15, 2024

Thanks man!
It's still working today. Don't forget to make the script executable

chmod +x  tmux-switch-pane.sh 

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