Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Forked from fieg/.bash_profile
Created November 16, 2015 20:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdeboard/9df3fe0a718bbca105f4 to your computer and use it in GitHub Desktop.
Save mattdeboard/9df3fe0a718bbca105f4 to your computer and use it in GitHub Desktop.
.bash_profile for OSX including autocomplete for ssh hosts, default variables and some aliases
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
cat ~/.ssh/config | \
grep "^Host " | \
awk '{print $2}'
`
COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
return 0
}
complete -F _complete_ssh_hosts ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment