diff options
author | zghember <zghpku@gmail.com> | 2015-01-03 14:41:34 +0800 |
---|---|---|
committer | zghember <zghpku@gmail.com> | 2015-01-03 14:41:34 +0800 |
commit | 8105d4acc960229e8c7fa9dc6936d8ce881c6b8d (patch) | |
tree | 3c3ead3f01aa7cfc645155a3c992f046ec328155 /plugins/yii2 | |
parent | 6fd0b73e9aba568640005798f737cd73ad0bfdf4 (diff) | |
parent | 175b4a807383530aa75145b5b6fdedb3ce1f11f2 (diff) | |
download | zsh-8105d4acc960229e8c7fa9dc6936d8ce881c6b8d.tar.gz zsh-8105d4acc960229e8c7fa9dc6936d8ce881c6b8d.tar.bz2 zsh-8105d4acc960229e8c7fa9dc6936d8ce881c6b8d.zip |
Merge commit '175b4a807383530aa75145b5b6fdedb3ce1f11f2'
Diffstat (limited to 'plugins/yii2')
-rw-r--r-- | plugins/yii2/README.md | 7 | ||||
-rw-r--r-- | plugins/yii2/yii2.plugin.zsh | 29 |
2 files changed, 36 insertions, 0 deletions
diff --git a/plugins/yii2/README.md b/plugins/yii2/README.md new file mode 100644 index 000000000..345b66eb6 --- /dev/null +++ b/plugins/yii2/README.md @@ -0,0 +1,7 @@ +# Yii2 autocomplete plugin + +* Adds autocomplete commands and subcommands for yii. + +## Requirements + +Autocomplete works from directory where your `yii` file contains. diff --git a/plugins/yii2/yii2.plugin.zsh b/plugins/yii2/yii2.plugin.zsh new file mode 100644 index 000000000..e8993adf4 --- /dev/null +++ b/plugins/yii2/yii2.plugin.zsh @@ -0,0 +1,29 @@ +# Yii2 command completion + +_yii2_format_command () { + awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }' +} + +_yii2 () { + if [ -f ./yii ]; then + _arguments \ + '1: :->command'\ + '*: :->params' + + case $state in + command) + + local -a commands + local -a name + + if [[ $words[2] == *\/ ]]; then + name=$words[2] + fi + + commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"}) + compadd -Q -S '' -a -- commands + esac + fi +} + +compdef _yii2 yii
\ No newline at end of file |