Skip to content

Instantly share code, notes, and snippets.

@innocuo
Created July 9, 2018 16:40
Show Gist options
  • Save innocuo/03bac97e181df280bfd2446efea309e3 to your computer and use it in GitHub Desktop.
Save innocuo/03bac97e181df280bfd2446efea309e3 to your computer and use it in GitHub Desktop.
Add this to .bash_profile to list all hosts from your .ssh/config file
#list all hosts in .ssh/config
#if you add an argument, it lists all hosts that contain that word
whatssh(){
if [[ $# -eq 0 ]]; then
grep -w -i "Host" ~/.ssh/config | sed 's/[Hh]ost//'
else
grep -i "^Host\s\+.*$1.*$" ~/.ssh/config | sed 's/[Hh]ost//'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment