From 00b2cc653421c1465f7596f22c19d21f42aa0396 Mon Sep 17 00:00:00 2001 From: Andrew Dwyer Date: Sat, 21 Dec 2013 11:17:05 +1030 Subject: [PATCH 1/3] New plugin for the n98-magerun Magento command line tool --- plugins/n98-magerun/n98-magerun.plugin.zsh | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 plugins/n98-magerun/n98-magerun.plugin.zsh diff --git a/plugins/n98-magerun/n98-magerun.plugin.zsh b/plugins/n98-magerun/n98-magerun.plugin.zsh new file mode 100755 index 00000000..e4b0d688 --- /dev/null +++ b/plugins/n98-magerun/n98-magerun.plugin.zsh @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# FILE: n98-magerun.plugin.zsh +# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin +# AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com) +# VERSION: 1.0.0 +# ------------------------------------------------------------------------------ + +# n98-magerun basic command completion +_n98_magerun_get_command_list () { + n98-magerun.phar --no-ansi | sed "1,/Available commands/d" | awk '/^\s+[a-z]+/ { print $1 }' +} + +_n98_magerun () { + compadd `_n98_magerun_get_command_list` +} + +compdef _n98_magerun n98-magerun.phar + +# Aliases +alias n98-magerun='n98-magerun.phar' +alias mage='n98-magerun.phar' +alias magefl='n98-magerun.phar cache:flush' + +# Install n98-magerun into the current directory +alias mage-get='wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar' From de769058b9bb846cdbda8eadfde7ebc1bad3993d Mon Sep 17 00:00:00 2001 From: Andrew Dwyer Date: Sat, 9 May 2015 14:33:01 +0930 Subject: [PATCH 2/3] Fix awk command. \s only working in gawk --- plugins/n98-magerun/n98-magerun.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/n98-magerun/n98-magerun.plugin.zsh b/plugins/n98-magerun/n98-magerun.plugin.zsh index e4b0d688..3a29f39b 100755 --- a/plugins/n98-magerun/n98-magerun.plugin.zsh +++ b/plugins/n98-magerun/n98-magerun.plugin.zsh @@ -7,7 +7,7 @@ # n98-magerun basic command completion _n98_magerun_get_command_list () { - n98-magerun.phar --no-ansi | sed "1,/Available commands/d" | awk '/^\s+[a-z]+/ { print $1 }' + n98-magerun.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }' } _n98_magerun () { @@ -15,9 +15,10 @@ _n98_magerun () { } compdef _n98_magerun n98-magerun.phar +compdef _n98_magerun n98-magerun # Aliases -alias n98-magerun='n98-magerun.phar' +alias n98='n98-magerun.phar' alias mage='n98-magerun.phar' alias magefl='n98-magerun.phar cache:flush' From 2449e41248f03f4313e67294883cb928d597ad27 Mon Sep 17 00:00:00 2001 From: Andrew Dwyer Date: Sat, 9 May 2015 15:43:30 +0930 Subject: [PATCH 3/3] Add file completion as optional argument --- plugins/n98-magerun/n98-magerun.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/n98-magerun/n98-magerun.plugin.zsh b/plugins/n98-magerun/n98-magerun.plugin.zsh index 3a29f39b..bfcf27b9 100755 --- a/plugins/n98-magerun/n98-magerun.plugin.zsh +++ b/plugins/n98-magerun/n98-magerun.plugin.zsh @@ -7,11 +7,19 @@ # n98-magerun basic command completion _n98_magerun_get_command_list () { - n98-magerun.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }' + $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z\-:]+/ { print $1 }' } + _n98_magerun () { - compadd `_n98_magerun_get_command_list` + _arguments '1: :->command' '*:optional arg:_files' + + case $state in + command) + compadd $(_n98_magerun_get_command_list) + ;; + *) + esac } compdef _n98_magerun n98-magerun.phar