Reputation: 3298
Example:
Let's assume we want to complete a command called rumple
. rumple
takes a list of files from ~/rumple
as argument (possibly nested directories/files). A valid invocation may be:
rumple pumple romple/pample
Which means rumple
shall effectively work on ~/rumple/pumple
and ~/rumple/romple/pample
.
Now the zsh-completion script _rumple
for rumple could look like:
#compdef rumple
_path_files -W ~/rumple
This completes the first part of the task: rumple p<TAB>
will complete to rumple pumple
(assuming there are not other files in ~/rumple starting with 'p'). However the second part is not working. rumple **/p*
should complete to rumple pumple romple/pample
, even if the current working directory is not ~/rumple
.
Upvotes: 2
Views: 335
Reputation: 1460
Normally you would leave it to the user to configure this sort of behaviour via the _match
completer or glob_complete
option.
But you can force it to some extent as follows:
#compdef rumple
local a=( ~/rumple/**/* )
compstate[pattern_match]='*'
compadd ${a#$HOME/rumple/}
Upvotes: 1