This repository has been archived on 2020-09-21. You can view files and clone it, but cannot push or open issues or pull requests.
zim/modules/completion/init.zsh
Matt Hamilton 01838f0083 add compdef for pacman aliases
The recommended order for the module loading has been changed. The last
module to be loaded should be 'completion'. This ensures all completions
set by other modules are dumped and included in the completion.
Because of this, any compdefs like this one (making the pacman aliases
use pacman completion) must be set in the compdefs.zsh file, and loaded
with the completion module. This means the compdefs must be wrapped with
conditional statements to ensure such aliases/functions have been set by
previous modules. I may abstract this conditional to a function in the
future to make this an easier process.
2015-12-17 03:06:12 -05:00

113 lines
3.5 KiB
Bash

#
# Completion enhancements
#
#
# initialization
#
# if it's a dumb terminal, return.
if [[ ${TERM} == 'dumb' ]]; then
return 1
fi
# add the completions to the fpath
fpath=(${0:h}/external/src ${fpath})
# load and initialize the completion system
autoload -Uz compinit && compinit -C -d ${ZDOTDIR:-$HOME}/.zcompdump
# set any compdefs
source ${0:h}/compdefs.zsh
{
# zcomple the .zcompdump in the background
local zcompdump=${ZDOTDIR:-$HOME}/.zcompdump
if [[ -s ${zcompdump} && ( ! -s ${zcompdump}.zwc || ${zcompdump} -nt ${zcompdump}.zwc) ]]; then
zcompile ${zcompdump}
fi
unset zcompdump
} &!
#
# zsh options
#
# If a completion is performed with the cursor within a word, and a full completion is inserted,
# the cursor is moved to the end of the word
setopt ALWAYS_TO_END
# Automatically use menu completion after the second consecutive request for completion
setopt AUTO_MENU
# Automatically list choices on an ambiguous completion.
setopt AUTO_LIST
# Perform a path search even on command names with slashes in them.
setopt PATH_DIRS
# Make globbing (filename generation) sensitive to case.
unsetopt CASE_GLOB
# On an ambiguous completion, instead of listing possibilities or beeping, insert the first match immediately.
# Then when completion is requested again, remove the first match and insert the second match, etc.
unsetopt MENU_COMPLETE
#
# completion module options
#
# group matches and describe.
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' verbose yes
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# directories
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
zstyle ':completion:*' squeeze-slashes true
# enable caching
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.zcompcache"
# ignore useless commands and functions
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
# completion sorting
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# Man
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
# history
zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list false
zstyle ':completion:*:history-words' menu yes
# ignore multiple entries.
zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
# smart editor completion
zstyle ':completion:*:(nano|vim|nvim|vi|emacs|e):*' ignored-patterns '*.(wav|mp3|flac|ogg|mp4|avi|mkv|webm|iso|dmg|so|o|a|bin|exe|dll|pcap|7z|zip|tar|gz|bz2|rar|deb|pkg|gzip|pdf|mobi|epub|png|jpeg|jpg|gif)'