Created
November 10, 2017 09:48
-
-
Save lifeofguenter/10a71f7af123e0c4b694729944f88f48 to your computer and use it in GitHub Desktop.
~/.bash_completion.d/
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
# http://fahdshariff.blogspot.co.za/2011/04/writing-your-own-bash-completion.html | |
# https://unix.stackexchange.com/a/181603/111459 | |
_ssh() { | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts=$(grep --no-messages '^Host' ~/.ssh/config ~/.ssh/config.d/* | grep -v '[?*]' | cut -d ' ' -f 2-) | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
} | |
complete -F _ssh ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment