shownotes-w3m-rice/fzf_speed/_tmux_bell,--.list.and.jump.to.window.with.bell.alert

21 lines
874 B
Plaintext
Raw Normal View History

2021-07-03 23:23:15 +00:00
#!/usr/bin/env sh
# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry|odysee)
# https://www.youtube.com/user/gotbletu
# NOTE: simulate a bell alert on a window: $ sleep 3 && echo -e "\a"
# tmux list-pane formating
TARGET_SPEC="#{session_name}:#{window_id}:#{pane_id}:"
LIST_DATA="#{window_name} #{pane_title} #{window_bell_flag} #{pane_current_path} #{pane_current_command}"
FZF_COMMAND() {
fzf -e -i --prompt="Go to bell alert pane: " --info=default --layout=reverse --tiebreak=index
}
# select pane
LINE="$(tmux list-panes -a -F "$TARGET_SPEC $LIST_DATA" | awk '$4 == "1" {print $0}' | FZF_COMMAND)" || exit 0
SESSION="$(echo "$LINE" | cut -d ':' -f1)"
WINDOW_NUM="$(echo "$LINE" | cut -d ':' -f2)"
PANE_NUM="$(echo "$LINE" | cut -d ':' -f3)"
tmux select-pane -t "$PANE_NUM" && tmux select-window -t "$WINDOW_NUM" && tmux switch-client -t "$SESSION"