Skip to content

Instantly share code, notes, and snippets.

@flashingpumpkin
Created December 8, 2011 14:26
Show Gist options
  • Save flashingpumpkin/1447125 to your computer and use it in GitHub Desktop.
Save flashingpumpkin/1447125 to your computer and use it in GitHub Desktop.
Auto completing for some commands from your hosts file
#!/bin/bash
# Choose one
complete -W "$(grep -E '^[0-9]' /etc/hosts | awk '{ print $2 }')" ssh scp rsync ping
complete -W "$(grep -E '^ssh' ~/.bash_history | awk '{ print $2 }')" ssh scp rsync
complete -W "$(grep -E '^(\w)' ~/.ssh/known_hosts | awk '{ print $1 }' | sort -u | cut -d ',' -f 1)" ssh scp rsync ping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment