Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I tweak zsh's completion system to complete “fake” files in some circumstances?

More precisely, the AVFS filesystem exposes archives as directories by creating a “fake directory” next to every archive. By default, it replicates the whole directory hierarchy under its mount point ~/.avfs. Furthermore, under ~/.avfs, for every archive file such as /tmp/foo.zip, besides the archive file itself ~/.avfs/tmp/foo.zip, there is a directory called ~/.avfs/tmp/foo.zip# which exposes the content of the archive. However this extra directory does not appear in the listing of ~/.avfs/tmp: it only exists when explicitly requested. (This is similar to how some automounters operate.)

mountavfs
cd ~/.avfs/tmp/foo.zip\#

When I type a command like the one above, foo.zip# doesn't appear as a completion under ~/.avfs/tmp/, since there is no such directory. How can I tell zsh that whenever there is a file whose full path $arc matches ~/.avfs/**/*.(tgz|zip)¹, it should pretend that there is a directory called ${arc}#?

(Note that I want the completion to work with every call to _files or _dirs, not just for the cd command. I'd prefer not to have to duplicate the code of the _files function, if possible.)

¹ and all the rest of the extensions

share|improve this question
    
Does ~/.avfs contain a "copy" of the whole file-system? –  richard Jun 16 at 14:13
    
@richard Yes, every /path/to/foo is visible as ~/.avfs/path/to/foo. –  Gilles Jun 16 at 15:46
    
This might be easier fixed in avfs. If it presented the default # directory entry for any files that matched the strings it supports, or even magic tested the files in a directory for what needed to have a # entry, then the completion would just work. I guess there would be a performance hit for something like find as it would now trawl through compressed files. –  mtm Jul 21 at 14:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.