9674a96b5bc296a767c2560757626bf2bc3a9ad3

Author
Frank Louwers <frank@openminds.be>
Committer
Frank Louwers <frank@openminds.be>
Date

Message

[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

Diff

 1diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh
 2index ba3765b83ce12893215ea45c10665ccd2517f2ef..b98bfec3469ed5006e5778cf5301406f6e3ea050 100644
 3--- a/plugins/pj/pj.plugin.zsh
 4+++ b/plugins/pj/pj.plugin.zsh
 5@@ -18,8 +18,11 @@ function pj() {
 6     file=$1
 7 
 8     if [[ "open" == "$file" ]] then
 9-        file=$2
10+        shift
11+        file=$*
12         cmd=(${(s: :)EDITOR})
13+    else
14+        file=$*
15     fi
16 
17     for project in $PROJECT_PATHS; do
18@@ -36,7 +39,14 @@ function pj() {
19 alias pjo="pj open"
20 
21 function _pj () {
22-    compadd `/bin/ls -l $PROJECT_PATHS 2>/dev/null | awk '{ print $9 }'`
23+    # might be possible to improve this using glob, without the basename trick
24+    typeset -a projects
25+    foreach i ($PROJECT_PATHS/*)
26+    do
27+        projects+=`basename $i`
28+    done
29+
30+    _arguments '*:file:($projects)'
31 }
32 
33 compdef _pj pj