#zdep options,modules
### vim:ft=zsh:foldmethod=marker
###
### zsh completion system
###
### zstyle :completion:<function>:<completer>:<command>:<argument>:<tag> _settings_
###
### Frank Terbeck <ft@bewatermyfriend.org>
### Last-Modified: Thu Jan 31 20:14:14 2008
###
### URI: <http://ft.bewatermyfriend.org/comp/zsh.html>
###
### global setup {{{
### zstyle was added in zsh 3.1.7
if ! zis_317 "atleast" ; then
function zstyle() { }
fi
### use caching for all completions
zstyle ':completion:*' use-cache on
if [[ ${ZRC_SOURCE_DIR} = ${HOME}/etc/zsh ]] ; then
zstyle ':completion:*' cache-path ${HOME}/etc/cache/zsh/
else
zstyle ':completion:*' cache-path ${HOME}/.zsh/cache/
fi
### what completers to use?
zstyle ':completion:::::' completer _complete _ignored _approximate
### add '..' and '.' dirs to completions
zstyle ':completion:*' special-dirs ..
### use perl
zstyle ':completion:*' use-perl on
### _urls setup
zstyle ':completion:*' urls ~/etc/zsh/urls
### normal completion is nice; sometimes, when I'm misspelling
### something, the zsh should assists in finding the correct words
### '-e' is needed to get the argument evaluated each time this is called
### this argument to max-errors allows one error in 3 characters.
### found in 'From Bash to Z Shell' Chapter 10 - great book, btw :)
### '-e' was added in 4.0
zis_40 "atleast" && \
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
### }}}
### formats & looks {{{
### these set up the presentation of completion lists
### descriptions are printed in yellow fg color, sorted in groups
if (( ${ZHAVE_COLORS} > 0 )) ; then
zstyle ':completion:*:descriptions' format "- %{${fg[yellow]}%}%d%{${reset_color}%} -"
zstyle ':completion:*:messages' format "- %{${fg[cyan]}%}%d%{${reset_color}%} -"
zstyle ':completion:*:corrections' format "- %{${fg[yellow]}%}%d%{${reset_color}%} - (%{${fg[cyan]}%}errors %e%{${reset_color}%})"
zstyle ':completion:*:default' \
select-prompt \
"%{${fg[yellow]}%}Match %{${fg_bold[cyan]}%}%m%{${fg_no_bold[yellow]}%} Line %{${fg_bold[cyan]}%}%l%{${fg_no_bold[red]}%} %p%{${reset_color}%}"
zstyle ':completion:*:default' \
list-prompt \
"%{${fg[yellow]}%}Line %{${fg_bold[cyan]}%}%l%{${fg_no_bold[yellow]}%} Continue?%{${reset_color}%}"
zstyle ':completion:*:warnings' \
format \
"- %{${fg_no_bold[red]}%}no match%{${reset_color}%} - %{${fg_no_bold[yellow]}%}%d%{${reset_color}%}"
zstyle ':completion:*' group-name ''
else
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*:messages' format "- %d -"
zstyle ':completion:*:corrections' format "- %d - (errors %e)"
zstyle ':completion:*:default' select-prompt "Match %m Line %l %p"
zstyle ':completion:*:default' list-prompt "Line %l Continue?"
zstyle ':completion:*:warnings' format "- no match - %d"
zstyle ':completion:*' group-name ''
fi
### manual pages are sorted into sections
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
### }}}
### reducing matches {{{
### functions starting with '_' are completion functions by convention
### these are not supposed to be called by hand. no completion needed.
zstyle ':completion:*:(functions|parameters|association-keys)' ignored-patterns '_*'
### normally I don't want to complete *.o and *~, so, I'll ignore them
### update: these patterns are not ignored for rm, since i might want to delete those files
#zstyle ':completion:*:(^rm):*:(all-|)files' ignored-patterns '*?.o' '*?\~'
### vi(m) can ignore even more files
zis_40 "atleast" && \
zstyle -e ':completion:*:*:vi(|m):*:(all-|)files' ignored-patterns \
'texfiles=(${PREFIX}*.tex);
(( ${#texfiles} > 0 )) \
&& reply=(*.(aux|dvi|log|ps|pdf|bbl|toc|lot|lof|latexmain)) \
|| reply=(*?.(lo|so|la|o))'
### in my $HOME/bin dir there are often vim backups *~,
### these are not to be completed...
### i've got ${HOME}/bin/html/ which is no command, _do_not_complete_it!
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '(aptitude-*|html|*\~)'
### don't complete lost+found dirs for 'cd'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#lost+found'
### special completions for (mpg|ogg)123
zstyle ':completion:*:*:mpg123:*' file-patterns '(#i)*.mp3:files:mp3\ files *(-/):directories:directories'
zstyle ':completion:*:*:ogg123:*' file-patterns '(#i)*.ogg:files:ogg\ files *(-/):directories:directories'
### weed out uninteresting users when completing '(command) ~<TAB>'
zstyle ':completion:*:*:*:*:users' ignored-patterns Debian-exim bitlbee games irc mail news postgres \
uucp backup daemon gnats list man nobody proxy sync \
www-data bin lp messagebus operator sys pokernetwork
### }}}
### menu completion/selection setup {{{
### enable menu completion
zstyle ':completion:*' menu select
### enable verbose completion; descriptions like: '-a -- list entries starting with .'
zstyle ':completion:*' verbose yes
zstyle ':completion:*:-command-:*:' verbose no
### default menu selection for a few commands
zstyle ':completion:*:*:(kill*|man):*' menu yes
### }}}
### matching setup {{{
### if i have 'rm file0' on the commandline
### i don't need "file0" in possible completions
zstyle ':completion:*:(rm|kill):*' ignore-line yes
### $hosts for <tab> completing hostnames
zstyle ':completion:*:(nc|ping|ssh|nmap|*ftp|telnet|finger):*' hosts $hosts
### i like kill <tab>, but i want more processes...
zstyle ':completion:*:processes' command 'ps --forest -A -o pid,user,cmd'
zstyle ':completion:*:*:kill:*:processes' sort false
zstyle ':completion:*:processes-names' command 'ps c -u ${USER} -o command | uniq'
### }}}
### list colorization {{{
### use $LS_COLORS for general completion
### Note: (s.:.) splits ${LS_COLORS} into an array
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
if (( ${ZHAVE_COLORS} > 0 )) ; then
### highlight parameters with uncommon names
zstyle ':completion:*:parameters' \
list-colors "=[^a-zA-Z]*=$color[red]"
### highlight aliases
zstyle ':completion:*:aliases' \
list-colors "=*=$color[green]"
### show that _* functions are not for normal use
### (not needed, since I don't complete _* functions at all)
#zstyle ':completion:*:functions' \
# list-colors "=_*=$color[red]"
### highlight the original input.
zstyle ':completion:*:original' \
list-colors "=*=$color[red];$color[bold]"
### highlight words like 'esac' or 'end'
zstyle ':completion:*:reserved-words' \
list-colors "=*=$color[red]"
### colorize hostname completion
zstyle ':completion:*:*:*:*:hosts' \
list-colors "=*=$color[cyan];$color[bg-black]"
### colorize username completion
zstyle ':completion:*:*:*:*:users' \
list-colors "=*=$color[red];$color[bg-black]"
### colorize processlist for 'kill'
zstyle ':completion:*:*:kill:*:processes' \
list-colors "=(#b) #([0-9]#) #([^ ]#)*=$color[cyan]=$color[yellow]=$color[green]"
fi
### }}}
### compdefs {{{
### ping should complete hosts aswell...
compdef _hosts ping
### my kmake() wrapper function should complete just as make does
### and add 'menuconfig' as a fake completion, because _make does not find it itself
compdef kmake=make
zstyle ':completion::complete:*kmake:*' fake menuconfig -buildclean -catconfig
### }}}