Merge pull request #1604 from franklouwers/master

Improve pj-plugin to support projects with spaces in their names + optimise code
This commit is contained in:
Robby Russell 2014-11-06 09:13:56 -08:00
commit ed01122804

View File

@ -18,8 +18,11 @@ function pj() {
file=$1 file=$1
if [[ "open" == "$file" ]] then if [[ "open" == "$file" ]] then
file=$2 shift
file=$*
cmd=(${(s: :)EDITOR}) cmd=(${(s: :)EDITOR})
else
file=$*
fi fi
for project in $PROJECT_PATHS; do for project in $PROJECT_PATHS; do
@ -36,7 +39,11 @@ function pj() {
alias pjo="pj open" alias pjo="pj open"
function _pj () { 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
projects=($PROJECT_PATHS/*)
projects=$projects:t
_arguments '*:file:($projects)'
} }
compdef _pj pj compdef _pj pj