Add ssf command

This commit is contained in:
Anton Zadvorny 2022-06-04 23:27:04 +03:00
parent 6489dc0441
commit ce705f4584
1 changed files with 14 additions and 0 deletions

14
home/.zsh/cmd/ssf.sh Executable file
View File

@ -0,0 +1,14 @@
### 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