2015-12-15 00:12:17 -05:00
|
|
|
#
|
|
|
|
# Completion enhancements
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# initialization
|
|
|
|
#
|
|
|
|
|
|
|
|
# if it's a dumb terminal, return.
|
|
|
|
if [[ ${TERM} == 'dumb' ]]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# add the completions to the fpath
|
2015-12-16 14:56:54 -05:00
|
|
|
fpath=(${0:h}/external/src ${fpath})
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# load and initialize the completion system
|
2016-04-16 17:56:46 -04:00
|
|
|
autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}"
|
2015-12-17 02:12:02 -05:00
|
|
|
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# zsh options
|
|
|
|
#
|
|
|
|
|
2018-12-15 16:54:32 -05:00
|
|
|
# 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.
|
2015-12-15 00:12:17 -05:00
|
|
|
setopt ALWAYS_TO_END
|
|
|
|
|
|
|
|
# Perform a path search even on command names with slashes in them.
|
|
|
|
setopt PATH_DIRS
|
|
|
|
|
2018-02-27 04:58:04 -05:00
|
|
|
# Make globbing (filename generation) not sensitive to case.
|
2018-12-15 16:54:32 -05:00
|
|
|
setopt NO_CASE_GLOB
|
2015-12-15 00:12:17 -05:00
|
|
|
|
2018-02-27 11:11:30 -05:00
|
|
|
# Don't beep on an ambiguous completion.
|
2018-12-15 16:54:32 -05:00
|
|
|
setopt NO_LIST_BEEP
|
2018-02-27 11:11:30 -05:00
|
|
|
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
#
|
|
|
|
# completion module options
|
|
|
|
#
|
|
|
|
|
|
|
|
# group matches and describe.
|
|
|
|
zstyle ':completion:*:*:*:*:*' menu select
|
2018-02-27 04:58:04 -05:00
|
|
|
zstyle ':completion:*:matches' group yes
|
|
|
|
zstyle ':completion:*:options' description yes
|
2015-12-15 00:12:17 -05:00
|
|
|
zstyle ':completion:*:options' auto-description '%d'
|
2018-02-27 04:58:04 -05:00
|
|
|
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:*' format '%F{yellow}-- %d --%f'
|
2015-12-15 00:12:17 -05:00
|
|
|
zstyle ':completion:*' group-name ''
|
|
|
|
zstyle ':completion:*' verbose yes
|
2018-04-03 09:55:43 -04:00
|
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**'
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# directories
|
2018-05-24 21:37:16 -04:00
|
|
|
if (( ! ${+LS_COLORS} )); then
|
|
|
|
# Locally use same LS_COLORS definition from utility module, in case it was not set
|
|
|
|
local LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
|
2018-05-21 21:58:51 -04:00
|
|
|
fi
|
2018-05-24 21:37:16 -04:00
|
|
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
2015-12-15 00:12:17 -05:00
|
|
|
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
|
2015-12-19 09:48:29 -05:00
|
|
|
zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
|
2015-12-15 00:12:17 -05:00
|
|
|
|
|
|
|
# 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'
|
2018-09-17 01:28:26 -04:00
|
|
|
|
|
|
|
# If the _my_hosts function is defined, it will be called to add the ssh hosts
|
|
|
|
# completion, otherwise _ssh_hosts will fall through and read the ~/.ssh/config
|
|
|
|
zstyle -e ':completion:*:*:ssh:*:my-accounts' users-hosts \
|
|
|
|
'[[ -f ${HOME}/.ssh/config && ${key} == hosts ]] && key=my_hosts reply=()'
|