#!/usr/bin/env bash clusters() { test -d ~/.dsh/group && ls ~/.dsh/group | tr ' ' "\n" | sort | uniq | awk '{print "tmux-cssh", $1 }' } servers() { test -f ~/.ssh/config && cat ~/.ssh/config | grep "^Host " | awk '{print $2}' | grep -v "*" | awk '{print "ssh", $1}' } commands() { local list list=$(tmux show-options -g -v @COMMANDS 2> /dev/null) if [ -z "$list" ] && [ -f ~/.tmux.conf.local ]; then # no tmux server (e.g. running inside herdr): read @COMMANDS from the static config instead list=$(grep -E '^\s*set-option\s+-g\s+@COMMANDS\s' ~/.tmux.conf.local \ | sed -E 's/^\s*set-option\s+-g\s+@COMMANDS\s+"([^"]*)".*/\1/') fi echo "$list" | tr ' ' '\n' | awk '{print $1}' } search() { clusters servers commands } search | fzf --layout=reverse --no-sort --prompt ' ' --pointer='➤ ' --marker='➤'