dotfiles/home/.zsh/cmd/ssf.sh
2022-06-04 23:27:04 +03:00

15 lines
355 B
Bash
Executable File

### 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