#!/bin/sh _args="$@" _f=$HOME/.ssh-bookmarks _sshopts="$(ssh 2>&1 | tr -d '[]' | tr '-' '\n' | grep "^. .*" | cut -b1 | tr -d ' \n')" while [[ $1 = -* ]] do printf "$_sshopts" | grep -q ${1#-} && shift shift done _b="${1##*\@}" [ ! -f "$_f" ] && printf '%s ' "set -A complete_ssh" > "$_f" grep -q "$_b" "$_f" || printf '"%s" ' "$_b" >> "$_f" ssh $_args