summaryrefslogtreecommitdiff
path: root/tmuxsh/_tmux_find_windows,--.search.all.window.and.jump
blob: a191d9c42a848161f5a9ed228317492e76e1c0c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env sh
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry|odysee)
#         https://www.youtube.com/user/gotbletu
# REFF:   https://gist.github.com/thugcee/41d1ba786fa5e66167ed6ee45e4f6346
#         https://eioki.eu/2021/01/12/tmux-and-fzf-fuzzy-tmux-session-window-pane-switcher
# CLOG:   changed from bash to posix

# tmux list-windows formating
TARGET_SPEC="#{session_name}:#{window_id}:"
LIST_DATA="#{window_name} #{pane_title} #{pane_current_path} #{pane_current_command}"

FZF_COMMAND() {
  fzf -e -i --prompt="Select a window: " --info=default --layout=reverse --tiebreak=index
}

# select window
LINE="$(tmux list-windows -a -F "$TARGET_SPEC $LIST_DATA" | FZF_COMMAND)" || exit 0
SESSION="$(echo "$LINE" |  cut -d ':' -f1)"
WINDOW_NUM="$(echo "$LINE" |  cut -d ':' -f2)"

tmux select-window -t "$WINDOW_NUM" && tmux switch-client -t "$SESSION"