Skip to content

Instantly share code, notes, and snippets.

@Chucky2401
Last active July 28, 2025 09:26
Show Gist options
  • Select an option

  • Save Chucky2401/9cd9e86d379c9fe9485be111b55cadcc to your computer and use it in GitHub Desktop.

Select an option

Save Chucky2401/9cd9e86d379c9fe9485be111b55cadcc to your computer and use it in GitHub Desktop.
SSH Connection with fzf
function conn_ssh() {
while read -r client; do
INFO=$(ssh -Gt "$client" 2>/dev/null | grep -E "^user |port " | tr '\n' ';' | sed 's/;$//')
printf "%s:%s\n" "$client" "$INFO"
done < <(grep -P "^Host ([^*]+)$" ~/.ssh/config | sed 's/Host //' | sort) | fzf --tmux center \
--prompt ' ' \
--pointer '󰛂' \
--border-label ' SSH Servers ' \
--delimiter=':' \
--with-nth '{1}' \
--preview 'echo {2} | sed "s/;/\n/"' \
--bind 'enter:become(ssh {1})'
}
bindkey -s '^g^n' 'conn_ssh\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment