All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
12 zstyle :compinstall filename "$ZDOTDIR/zshrc/80-completion"
15 compinit -d $ZVARDIR/comp-$HOSTS
17 # load fancy completion list and menu handler
20 # avoid old-style completion (compctl)
21 zstyle ':completion:*' use-compctl false
24 zstyle ':completion:*' use-cache on
25 zstyle ':completion:*' cache-path $ZVARDIR/compcache-${HOST}
29 # show the list of completions right away when there's an ambiguous prefix
30 # note that there's also the 'list' zstyle, which could override this
32 setopt no_list_ambiguous
34 # use menu after the second completion request
35 # cf. also the 'menu' zstyle, which eclipses this
38 # these mess with the aforementioned behaviour, make sure they're off
39 setopt no_menu_complete no_bash_auto_list
41 # make the completion list smaller by printing the matches in columns with
45 # do not recognise exact matches even if they're ambiguous
46 # (we don't want this because /var/log/sys<tab> should also
47 # offer /var/log/syslog…)
50 # move cursor to end of word being completed
53 # be magic about adding/removing final characters on tab completion
54 setopt auto_param_keys auto_param_slash auto_remove_slash
56 # allow completion to happen in the middle of a word
57 setopt complete_in_word
61 # set the list of completers
62 zstyle ':completion:*' completer \
63 _expand_alias _expand \
64 _complete _prefix:-complete \
65 _approximate _prefix:-approximate \
67 zstyle ':completion:*:prefix-complete:*' completer _complete
68 zstyle ':completion:*:prefix-approximate:*' completer _approximate
70 # configure the _expand completer
71 bindkey '^i' complete-word
72 zstyle ':completion::expand:*' tag-order 'expansions all-expansions original'
74 # do approximated completion, allowing 1 error per three characters
75 zstyle ':completion:*:approximate:' max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )'
77 ### TRIM OUTPUT OF IGNORED PATTERNS
79 # functions which start with _ are internal and ignored
80 zstyle ':completion:*:*:-command-:*' tag-order 'functions:-non-comp'
81 zstyle ':completion:*:functions-non-comp' ignored-patterns '_*'
83 # ignore working and backup copies, and compiled objects
84 zstyle ':completion:*:argument-rest:' file-patterns '
85 *(-/):directories:directories
86 (*.(ba#k|old)|*~):backup-files:"backup files"
87 *.(l#[oa]|py[co]|zwc):compiled-files:"compiled files"
88 *.te#mp:temp-files:"temp files"
89 .*.sw?:vim-swap-files:"vim swap files"
90 %p:globbed-files *:all-files
92 zstyle ':completion:*:argument-rest:(all|globbed)-files' ignored-patterns \
93 '((*.(ba#k|old)|*~)|*.(l#[oa]|py[co]|zwc)|*.te#mp|.*.sw?|*(-/))'
94 #TODO directories not ignored in files output:
95 #### fishbowl:/tmp/cdt.6kIDed% cat <tab>
101 #### foo.a foo.la foo.lo foo.o foo.pyc foo.zwc
105 #### foobar/ foo.c foo.txt
107 #zstyle ':completion:*:argument*' tag-order "
108 # globbed-files files all-files
115 zstyle ':completion:*:argument*' group-order \
117 globbed-files files all-files \
123 #TODO no effect on ordering yet
125 zstyle ':completion:*:argument*' group-order vim-swap-files directories \
126 globbed-files files all-files backup-files compiled-files temp-files
128 resource() { source $ZDOTDIR/zshrc/80-completion; zle -M "resourced"; }
130 bindkey '\er' resource
132 # do not offer files already specified on the line
133 zstyle ':completion:*:rm' ignore-line yes
135 # do not offer current directory as completion in ../
136 zstyle ':completion:*' ignore-parents parent pwd
138 # http://xana.scru.org/2005/08/20#ignorelatexjunk
139 zstyle -e ':completion:*:*:vim#' ignored-patterns \
140 'texfiles=$(echo ${PREFIX}*.tex); [[ -n "$texfiles" ]] &&
141 reply=(*.(aux|dvi|log|p(s|df)|bbl|toc|lo[tf]|latexmain)) || reply=()'
145 # Take advantage of $LS_COLORS for completion as well.
146 zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
148 # List directories first/in a separate group
149 zstyle ':completion:*' list-dirs-first yes
151 # Use a less ambiguous list separator
152 zstyle ':completion:*' list-separator '::'
154 # allow cursor-key navigation through completion set
155 zstyle ':completion:*' menu select
157 # always offer the original string as a completion choice
158 zstyle ':completion:*:match:*' original true
160 # squash multiple slashes to one, which is the unix-style
161 zstyle ':completion:*' squeeze-slashes true
163 # Formatting of completion menu/list
164 zstyle ':completion:*' verbose yes
165 zstyle ':completion:*' auto-description 'missing description: %d'
166 zstyle ':completion:*:descriptions' format '%B%d%b'
167 zstyle ':completion:*:messages' format '%d'
168 zstyle ':completion:*:warnings' format 'no matches for: %d'
169 zstyle ':completion:*:corrections' format "%B%d $fg[red](errors: %e)$reset_color%b"
170 #zstyle ':completion:*:matches' group 'yes'
171 zstyle ':completion:*' group-name ''
173 # Handle command-line options a bit differently
174 zstyle ':completion:*:options' auto-description '%d'
175 zstyle ':completion:*:options' description 'yes'
179 # ^x^h :: provide context help, in addition to ^x h
180 bindkey '^x^h' _complete_help
182 ### SPECIFIC COMMAND/CONTEXT HANDLING
184 # commands that take commands as arguments
185 compdef _precommand gdb
186 compdef _precommand nohup
187 compdef _precommand strace
189 # a couple commands don't yet have -option completion but
190 # they're generic GNU tools, so…
191 typeset -la gnu_generic_tools=(mv)
193 for c ($gnu_generic_tools) compdef _gnu_generic $c
195 # custom path when expanding in the sudo context
196 zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
204 # Completion of processes: show all user processes
205 zstyle ':completion:*:processes' command 'PS="ps -au$USER -o pid,tty,time,pcpu,cmd"; eval $PS | grep -v "$PS"'
207 # Integrate directory stack with cd -<tab> completion
208 zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
210 # Offer .. as a special-dir to completions
211 zstyle -e ':completion:*' special-dirs '[[ $PREFIX = (../)#(|.|..) ]] && reply=(..)'
212 #TODO does not yet work
214 # complete manual by their section
215 zstyle ':completion:*:manuals' separate-sections true
216 zstyle ':completion:*:manuals.*' insert-sections true
217 zstyle ':completion:*:man:*' menu yes select
220 zstyle ':completion::complete:xmms2:*:values' list-grouped false
221 zstyle ':completion::complete:xmms2:*:values' sort false