Last active
July 28, 2025 09:26
-
-
Save Chucky2401/9cd9e86d379c9fe9485be111b55cadcc to your computer and use it in GitHub Desktop.
SSH Connection with fzf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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