Created
August 5, 2011 22:13
-
-
Save bunnymatic/1128651 to your computer and use it in GitHub Desktop.
SSH Completion for bash based on .ssh/config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__from_ssh_config() { | |
SSHCONFIG=$HOME/.ssh/config | |
COMPREPLY=() | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=($(compgen -W '$(cat ~/.ssh/config | grep Host | cut -d" " -f2-)' -- $cur)) | |
} | |
complete -F __from_ssh_config -o default ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
save this somewhere and add the following to your profile
if [-f /path/to/ssh_completion/ ]; then
. /path/to/ssh_completion
fi
This will autocomplete the ssh command for any host you have defined in your .ssh/config file