Created
February 3, 2015 07:30
-
-
Save hayamiz/5c54e88a2bb9fa6bb5e0 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
| #compdef ec2ssh | |
| # main completion function | |
| _ec2ssh-init() { | |
| local ret | |
| _call_function ret __ec2ssh_noarg_cmd | |
| return $ret | |
| } | |
| _ec2ssh-migrate() { | |
| local ret | |
| _call_function ret __ec2ssh_noarg_cmd | |
| return $ret | |
| } | |
| _ec2ssh-remove() { | |
| local ret | |
| _call_function ret __ec2ssh_noarg_cmd | |
| return $ret | |
| } | |
| _ec2ssh-update() { | |
| local curcontext context state line | |
| declare -A opt_args | |
| integer ret=1 | |
| _arguments -C -S \ | |
| '--aws-key:aws key name' \ | |
| '--dotfile:ec2ssh dotfile:_files' \ | |
| '--verbose' && return | |
| return $ret | |
| } | |
| _ec2ssh-version() { | |
| local ret | |
| _call_function ret __ec2ssh_noarg_cmd | |
| return $ret | |
| } | |
| __ec2ssh_noarg_cmd() { | |
| local curcontext context state line | |
| declare -A opt_args | |
| integer ret=1 | |
| _arguments -C -S \ | |
| '--dotfile:ec2ssh dotfile:_files' \ | |
| '--verbose' && return | |
| return $ret | |
| } | |
| _ec2ssh() { | |
| local curcontext context state line | |
| declare -A opt_args | |
| integer ret=1 | |
| _arguments -C -S \ | |
| '--dotfile:ec2ssh dotfile:_files' \ | |
| '--verbose' \ | |
| '(-): :->commands' \ | |
| '(-)*:: :->option-or-argument' && return | |
| case $state in | |
| (commands) | |
| _ec2ssh_commands && ret=0 | |
| ;; | |
| (option-or-argument) | |
| if (( $+functions[_ec2ssh-$words[1]] )); then | |
| _call_function ret _ec2ssh-$words[1] | |
| else | |
| _message 'no completion' | |
| fi | |
| ;; | |
| esac | |
| return ret | |
| } | |
| _ec2ssh_commands() { | |
| _values 'command' \ | |
| 'help[Describe available commands or one specific command]' \ | |
| 'init[Add ec2ssh mark to ssh_config]' \ | |
| 'migrate[Migrate dotfile from old versions]' \ | |
| 'remove[Remove ec2ssh mark from ssh_config]' \ | |
| 'update[Update ec2 hosts list in ssh_config]' \ | |
| 'version[Show version]' | |
| } | |
| compdef _ec2ssh ec2ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment