ed011228044f8835c71da958839112b617fdd72e

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1604 from franklouwers/master

Improve pj-plugin to support projects with spaces in their names + optimise code

Diff

 1diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh
 2index ba3765b83ce12893215ea45c10665ccd2517f2ef..f9cbddf1aaeb8ef61856257183fc5faf1eed247c 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,11 @@ 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+    projects=($PROJECT_PATHS/*)
26+    projects=$projects:t 
27+    _arguments '*:file:($projects)'
28 }
29 
30 compdef _pj pj