Skip to content

Instantly share code, notes, and snippets.

@fieg
Created April 11, 2012 07:57
Show Gist options
  • Save fieg/2357723 to your computer and use it in GitHub Desktop.
Save fieg/2357723 to your computer and use it in GitHub Desktop.
.bash_profile for OSX including autocomplete for ssh hosts, default variables and some aliases
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/sbin:$PATH
export EDITOR=vim
export APPLICATION_ENV="development"
export CLICOLOR=1
export LSCOLORS=dxfxcxdxbxegedabagacad
alias composer="php /usr/local/bin/composer.phar"
_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
@difki
Copy link

difki commented Oct 13, 2018

Changed cat ~/.ssh/config --> ~/.ssh/known_host as I don't have ~/.ssh/config file.
Now it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment