dotfiles/home/.zsh/cmd/ssf.sh

15 lines
355 B
Bash
Raw Normal View History

2022-06-04 20:27:04 +00:00
### SSH
# mnemonic [SS]h [F]ind and connect
# find ssh host from known hosts and connect
host=${1}
if [[ -z $host ]]; then
host=$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | sort -u | eval "fzf ${FZF_DEFAULT_OPTS} -m --header='[ssh:connect]'" | awk '{print $1}')
fi
if [[ $host ]]; then
echo "Connecting to $host"
ssh $host
fi