-
-
Save andypiper/5009668 to your computer and use it in GitHub Desktop.
zsh plugin for vmc (pre-ng version)
based on the brew zsh plugin, delete the stuff towards the end. install to .oh-my-zsh/custom/vmc and enable in .zshrc
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 vmc | |
#autoload | |
# vmc autocompletion for oh-my-zsh | |
# requires: the vmc gem (gem install vmc) | |
# author: Andy Piper (http://andypiper.co.uk) | |
_list_apps() { | |
for APP in `vmc apps | grep -oE '^\| [[:alnum:]-]+ . ' | grep -oE '[[:alnum:]-]+'`; do | |
compadd "$@" $APP | |
done | |
} | |
_list_system_service() { | |
for SERVICE in `vmc services | grep -oE '\| [[:alnum:]]+[ ]+\| [[:digit:]]' | grep -oE '[[:alnum:]]+ '`; do | |
compadd "$@" $SERVICE | |
done | |
} | |
_list_service_name() { | |
for SERVICE_NAME in `vmc services | grep -oE '\| [[:alnum:]-]+[ ]+\| [[:lower:]]' | grep -oE '[[:alnum:]-]+[ ]+\|' | grep -oE '.* '`; do | |
compadd "$@" $SERVICE_NAME | |
done | |
} | |
local -a _1st_arguments | |
_1st_arguments=( | |
'add-user:register a new user (requires admin privileges)' | |
'alias:create an alias for a command' | |
'aliases:list aliases' | |
'apps:list deployed applications' | |
'bind-service:bind a service to an application' | |
'clone-services:clone service bindings between applications' | |
'crashes:list recent application crashes' | |
'crashlogs:display log information for crashed applications' | |
'create-service:create a provisioned service' | |
'delete-service:delete a provisioned service' | |
'delete-user:delete a user and all apps and services (requires admin privileges)' | |
'delete:delete an application' | |
'env-add:add an environment variable to an application' | |
'env-del:add an environment variable from an application' | |
'env:list application environment variables' | |
'files:display directory listing or download file' | |
'frameworks:display the recognized frameworks of the target system' | |
'help:get help on commands and options' | |
'info:system and account information' | |
'instances:scale application instances up or down' | |
'login:login to the target system' | |
'logout:log the current user out of the target system' | |
'logs:display log information for an application' | |
'map:register an application to a URL' | |
'mem:update the memory reservation for an application' | |
'passwd:change the password for the current user' | |
'push:create, push, map, and start a new application' | |
'restart:restart an application' | |
'runtimes:display the supported runtimes of the target system' | |
'services:list available and provisioned services' | |
'start:start an application' | |
'stats:display resource usage for an application' | |
'stop:stop an application' | |
'target:reports current target or sets a new target' | |
'targets:list known targets and associated authorization tokens' | |
'tunnel:create a local tunnel to a service' | |
'unalias:remove an alias' | |
'unbind-service:unbind a service from an application' | |
'unmap:unregister an application from a URL' | |
'update:update the application bits' | |
'user:display user account information' | |
) | |
local expl | |
local -a apps services | |
_arguments \ | |
'(-v)-v[verbose]' \ | |
'(--cellar)--cellar[brew cellar]' \ | |
'(--config)--config[brew configuration]' \ | |
'(--env)--env[brew environment]' \ | |
'(--repository)--repository[brew repository]' \ | |
'(--version)--version[version information]' \ | |
'(--prefix)--prefix[where brew lives on this system]' \ | |
'(--cache)--cache[brew cache]' \ | |
'*:: :->subcmds' && return 0 | |
if (( CURRENT == 1 )); then | |
_describe -t commands "vmc subcommand" _1st_arguments | |
return | |
fi | |
case "$words[1]" in | |
search|-S) | |
_arguments \ | |
'(--macports)--macports[search the macports repository]' \ | |
'(--fink)--fink[search the fink repository]' ;; | |
list|ls) | |
_arguments \ | |
'(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ | |
'(--versions)--versions[list all installed versions of a formula]' \ | |
'1: :->forms' && return 0 | |
if [[ "$state" == forms ]]; then | |
_brew_installed_formulae | |
_wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae | |
fi ;; | |
start|stop|restart|delete|update|mem|map|unmap|instances) | |
_list_apps | |
_wanted apps expl 'all apps' compadd -a apps ;; | |
crashes|crashlogs|logs|files|stats|env|env-add|env-del) | |
_list_apps | |
_wanted apps expl 'all apps' compadd -a apps ;; | |
# install|home|homepage|log|info|abv|uses|cat|deps|edit|options) | |
# _brew_all_formulae | |
# _wanted formulae expl 'all formulae' compadd -a formulae ;; | |
# remove|rm|uninstall|unlink|cleanup|link|ln) | |
# _brew_installed_formulae | |
# _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment