#!/usr/bin/env bash if [[ $# -eq 1 ]]; then selected=$1 else selected=$(grep -P "^Host ([^*]+)$" $HOME/.ssh/config | sed 's/Host //' | sort -r -f | fzf) fi if [[ -z $selected ]]; then exit 0 fi ssh $selected