浏览代码

Fix _pj completion function

- `$PROJECT_PATHS/*` wasn't working correctly. You have to iterate over
  its elements in order to use globbing with it.

- The `$projects:t` line wasn't necessary if we used `compadd`.

- `compadd` better supports destructuring an array with spaces in some
  of its elements.
Marc Cornellà 8 年之前
父节点
当前提交
c9c11d605f
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      plugins/pj/pj.plugin.zsh

+ 7 - 4
plugins/pj/pj.plugin.zsh

@@ -24,10 +24,13 @@ function pj () {
 }
 
 function _pj () {
-    # might be possible to improve this using glob, without the basename trick
+    emulate -L zsh
+
     typeset -a projects
-    projects=($PROJECT_PATHS/*)
-    projects=$projects:t
-    _arguments "*:file:($projects)"
+    for basedir ($PROJECT_PATHS); do
+        projects+=(${basedir}/*(/N))
+    done
+
+    compadd ${projects:t}
 }
 compdef _pj pj