From c9c11d605f28c0a93ad34ba2a40120ea6e0f9dc0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 11 Aug 2016 01:35:45 +0200 Subject: 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. --- plugins/pj/pj.plugin.zsh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/pj/pj.plugin.zsh b/plugins/pj/pj.plugin.zsh index 8b1bc883f..1d89af00b 100644 --- a/plugins/pj/pj.plugin.zsh +++ b/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 -- cgit v1.2.3-70-g09d2