home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

completion.zsh (4391B)


      1 zstyle ':completion:*' menu select
      2 # Use caching to make completion for commands such as dpkg and apt usable.
      3 zstyle ':completion::complete:*' use-cache on
      4 zstyle ':completion::complete:*' cache-path "$ZSH_CACHE/zcompcache"
      5 
      6 # Case-insensitive (all), partial-word, and then substring completion.
      7 zstyle ':completion:*' matcher-list '' \
      8        'm:{a-z\-}={A-Z\_}' \
      9        'r:[^[:alpha:]]||[[:alpha:]]=** r:|=* m:{a-z\-}={A-Z\_}' \
     10        'r:[[:ascii:]]||[[:ascii:]]=** r:|=* m:{a-z\-}={A-Z\_}'
     11 
     12 # Group matches and describe.
     13 zstyle ':completion:*:*:*:*:*' menu select
     14 zstyle ':completion:*:matches' group 'yes'
     15 zstyle ':completion:*:options' description 'yes'
     16 zstyle ':completion:*:options' auto-description '%d'
     17 zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
     18 zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
     19 zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
     20 zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
     21 zstyle ':completion:*:default' list-prompt '%S%M matches%s'
     22 zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
     23 zstyle ':completion:*' group-name ''
     24 zstyle ':completion:*' verbose yes
     25 
     26 # Fuzzy match mistyped completions.
     27 zstyle ':completion:*' completer _complete _list _match _approximate
     28 zstyle ':completion:*:match:*' original only
     29 zstyle ':completion:*:approximate:*' max-errors 1 numeric
     30 
     31 # Increase the number of errors based on the length of the typed word.
     32 zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
     33 
     34 # Don't complete unavailable commands.
     35 zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
     36 
     37 # Array completion element sorting.
     38 zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
     39 
     40 # Directories
     41 zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
     42 zstyle ':completion:*:*:cd:*' ignore-parents parent pwd
     43 zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
     44 zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
     45 zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
     46 zstyle ':completion:*' squeeze-slashes true
     47 zstyle ':completion:*' special-dirs true
     48 # Environmental Variables
     49 zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-}
     50 
     51 # Populate hostname completion.
     52 zstyle -e ':completion:*:hosts' hosts 'reply=(
     53   ${=${=${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//\]:[0-9]*/ }//,/ }//\[/ }
     54   ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
     55 )'
     56 
     57 # Don't complete uninteresting users...
     58 zstyle ':completion:*:*:*:users' ignored-patterns \
     59   adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
     60   dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
     61   hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
     62   mailman mailnull mldonkey mysql nagios \
     63   named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
     64   operator pcap postfix postgres privoxy pulse pvm quagga radvd \
     65   rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs '_*'
     66 
     67 # ... unless we really want to.
     68 zstyle '*' single-ignored show
     69 
     70 # Ignore multiple entries.
     71 zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
     72 zstyle ':completion:*:rm:*' file-patterns '*:all-files'
     73 
     74 # Man
     75 zstyle ':completion:*:manuals' separate-sections true
     76 zstyle ':completion:*:manuals.(^1*)' insert-sections true
     77 
     78 # SSH/SCP/RSYNC
     79 zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
     80 zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
     81 zstyle ':completion:*:ssh:*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
     82 zstyle ':completion:*:ssh:*' group-order users hosts-domain hosts-host users hosts-ipaddr
     83 zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
     84 zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*'
     85 zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*'