Last active
August 29, 2015 14:14
-
-
Save hayamiz/6928b60c54e7a89fc57b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # bash completion support for ec2ssh | |
| _ec2ssh() { | |
| local cmd cur prev subcmd | |
| cmd=$1 | |
| cur=$2 | |
| prev=$3 | |
| subcmds="help init migrate remove update version" | |
| common_opts="--dotfile --verbose" | |
| # contextual completion | |
| case $prev in | |
| ec2ssh) | |
| case "$cur" in | |
| -*) | |
| COMPREPLY=( $(compgen -W "$common_opts" $cur) ) | |
| ;; | |
| *) | |
| COMPREPLY=( $(compgen -W "$subcmds" $cur) ) | |
| esac | |
| return 0 | |
| ;; | |
| --aws-key) | |
| COMPREPLY=() | |
| return 0; | |
| ;; | |
| --dotfile) | |
| COMPREPLY=( $(compgen -o default -- "$cur")) | |
| return 0; | |
| ;; | |
| esac | |
| # complete options | |
| subcmd=${COMP_WORDS[1]} | |
| case $subcmd in | |
| update) | |
| COMPREPLY=( $(compgen -W "--aws-key $common_opts" -- "$cur") ) | |
| ;; | |
| help) | |
| COMPREPLY=( $(compgen -W "$subcmds" $cur) ) | |
| ;; | |
| *) | |
| COMPREPLY=( $(compgen -W "$common_opts" -- "$cur") ) | |
| ;; | |
| esac | |
| return 0 | |
| } | |
| complete -F _ec2ssh ec2ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment