Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Source-File Favoring Completion Revised



I think I've finally got the completion I'm looking for to complete
source code files before executable or binary files for text editors.
Here's what I have:

   # I don't typically open these files with my text editor.
   zstyle ':completion:*:src-files' ignored-patterns \
          '*?.o' '*?.pdf' '*?.aux' '*?.log'

   # This function filters out executable files who have a source code
   # namesake.  File test will not be returned if test.c exists.
   src_files() {
      if [[ -e $REPLY.c ]]; then
         reply=""
      else
         reply=$REPLY
      fi
   }

   # Complete src_files before others.
   zstyle ':completion:*:*:(emacs|vi|vim):*' file-patterns \
          '%p(e,src_files,):src-files' '*:all-files'

This appears to work well for opening *.c and *.tex instead of the
unreadable binary files that are generated from the source.  Any input
is appreciated!

-- 
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson



Messages sorted by: Reverse Date, Date, Thread, Author