From 9674a96b5bc296a767c2560757626bf2bc3a9ad3 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 13 Feb 2013 12:02:36 +0100 Subject: [PATCH 1/3] [pj-plugin] delete ugly ls -l | awk print $9 thing to use something not depending on date format + add support for projects with spaces in them --- plugins/pj/pj.plugin.zsh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index ba3765b8..b98bfec3 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -18,8 +18,11 @@ function pj() { file=$1 if [[ "open" == "$file" ]] then - file=$2 + shift + file=$* cmd=(${(s: :)EDITOR}) + else + file=$* fi for project in $PROJECT_PATHS; do @@ -36,7 +39,14 @@ function pj() { alias pjo="pj open" function _pj () { - compadd `/bin/ls -l $PROJECT_PATHS 2>/dev/null | awk '{ print $9 }'` + # might be possible to improve this using glob, without the basename trick + typeset -a projects + foreach i ($PROJECT_PATHS/*) + do + projects+=`basename $i` + done + + _arguments '*:file:($projects)' } compdef _pj pj From df67f2ee30dbad61117e1886b0a4de326cb6daf7 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 13 Feb 2013 13:39:47 +0100 Subject: [PATCH 2/3] [pj-plugin] avoid using basename. migth be (a lot?) faster --- plugins/pj/pj.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index b98bfec3..dac56118 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -43,7 +43,7 @@ function _pj () { typeset -a projects foreach i ($PROJECT_PATHS/*) do - projects+=`basename $i` + projects+=(${i##*/}) done _arguments '*:file:($projects)' From bce74975d055529cbd186782e2fd99e6da840460 Mon Sep 17 00:00:00 2001 From: Frank Louwers Date: Wed, 28 May 2014 13:57:25 +0200 Subject: [PATCH 3/3] =?UTF-8?q?drop=20the=20foreach,=20make=20it=20even=20?= =?UTF-8?q?shorter.=20thanks=20Marc=20Cornell=C3=A0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/pj/pj.plugin.zsh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index dac56118..f9cbddf1 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/plugins/pj/pj.plugin.zsh @@ -41,11 +41,8 @@ alias pjo="pj open" function _pj () { # might be possible to improve this using glob, without the basename trick typeset -a projects - foreach i ($PROJECT_PATHS/*) - do - projects+=(${i##*/}) - done - + projects=($PROJECT_PATHS/*) + projects=$projects:t _arguments '*:file:($projects)' }