Skip to content

Instantly share code, notes, and snippets.

@nalakawula
Forked from thugcee/tmux-switch-pane.sh
Created February 15, 2024 01:52
Show Gist options
  • Save nalakawula/bc381453d8dbe725934630fb969fb31f to your computer and use it in GitHub Desktop.
Save nalakawula/bc381453d8dbe725934630fb969fb31f 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment