Shell – Ignore files for zsh’s completion for SVN

autocompleteshellsubversionzsh

I managed to configure zsh such that it does not suggest LaTeX temporary files when I use autocompletion for emacs by adding this line to my ~/.zshrc:

zstyle ':completion:*:*:emacs:*:*files' ignored-patterns '*?.aux' '*?.bbl' \
'*?.blg' '*?.out' '*?.log' '*?.toc' '*?.snm' '*?.nav' '*?.pdf' '*?.bak' '*\~'

Now zsh ignores all LaTeX temporary files when I request completions for emacs.

How can I achieve the same for svn add?

So far I have only found out that the completion for svn is rather complicated and was even broken for some time. Just exchanging emacs in the above example does not work because I need to affect the completion for the add parameter of svn.

Best Answer

This line will give you what you want:

zstyle ':completion:*:*:svn-add:*:*files' ignored-patterns '*?.aux' '*?.bbl' \
'*?.blg' '*?.out' '*?.log' '*?.toc' '*?.snm' '*?.nav' '*?.pdf' '*?.bak' '*\~'

From http://zsh.sourceforge.net/Doc/Release/Completion-System.html:

The command or a special -context-, just at it appears following the #compdef tag or the compdef function. Completion functions for commands that have sub-commands usually modify this field to contain the name of the command followed by a minus sign and the sub-command. For example, the completion function for the cvs command sets this field to cvs-add when completing arguments to the add subcommand.

Related Question