#!/bin/sh -e
#
# ---
# source: https://github.com/Schniz/dotfiles

tmux list-sessions -F "#{session_name};;#{pane_current_path};;#{pane_current_command};;#{session_flags}" \
  | sed 's/;;/\t/g' \
  | awk '{ printf "\033[0;35m%s\t\033[1;37m%s\033[0;37m:\033[1;33m%s\t\033[0;37m\033[02;36m%s\033[0;37m\n", $1, $2, $3, $4 }' \
  | IFS=$(printf ' \n\t') column -ts ' ' \
  | fzf --tmux --ansi --header "select a tmux window" \
  | awk '{ print $1 }' \
  | xargs -I {} tmux switch-client -t {}
