aboutsummaryrefslogtreecommitdiff
path: root/scripts/tmux_session_fzf
blob: 4f5a96e201b8d3f091368e6dc957d6233e49620c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# vim: set filetype=sh
#
# Author: Cody Hiar
# Date: 2020-03-17
#
# Description: Switch to a different tmux session
#

get_active_pane(){
    local SESSION="${1}"
    tmux list-windows -t "${SESSION}" | grep '(active)' | cut -c 1
}

TARGET=$(tmux ls | awk -F':' '{print $1}' | fzf-tmux)
if [[ -n "${TARGET}" ]]; then
    WINDOW=$(get_active_pane "${TARGET}")
    echo "${TARGET}:${WINDOW}" >> ~/tmux.log
    tmux switch-client -t "${TARGET}:${WINDOW}"
fi