Is it possible to make a custom zsh completion file,so when hitting tab for filenames it avoids completing the binaries? For example,I have 2 files , myprogram.c and myprogram,the binary,is it possible so when I do vim myprog(tab) it automagically completes it to myprogram.c,not myprogram? Thanks in advance!
For example, to ignore
*.o files when completing files to edit with vim, you can put this in your
zstyle ':completion:*:*:vim:*:*files' ignored-patterns '*.o'
This won't work to exclude executables in a useful way. You can exclude
*~*.*, or more precisely
(|*/)[^/.]##, but this excludes every file name that doesn't contain a
., including scripts and even worse directories. As far as I know, the completion ignore mechanism can't check for the existence or type of files, it just matches text patterns.
You could of course tinker with this so that it worked for any given folder or set of files, but first you should understand the reason it doesn't do that now.
On linux, file extensions don't matter, the only thing that matters is the execute bit. Things can be executed whether they are really binary or just text in the form of a script. Your criteria of "not binaries" does not match up well with the distinctions made by Linux about what a file is or isn't.
That being said it wouldn't be too hard to write a custom completion function to replace the file name glob completion for a given command that would list all files but exclude the ones that have '.c' versions. It would require some overhead that would slow the tab completion down a little.