-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompletion.zsh
109 lines (80 loc) · 3.85 KB
/
completion.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Original source: https://github.com/Phantas0s/.dotfiles/blob/master/zsh/completion.zsh
# ____ ___ __ __ ____ _ _____ _____ ___ ___ _ _
# / ___/ _ \| \/ | _ \| | | ____|_ _|_ _/ _ \| \ | |
# | | | | | | |\/| | |_) | | | _| | | | | | | | \| |
# | |__| |_| | | | | __/| |___| |___ | | | | |_| | |\ |
# \____\___/|_| |_|_| |_____|_____| |_| |___\___/|_| \_|
#
# +---------+
# | General |
# +---------+
# source ./gambit.zsh
# Load more completions
# fpath=($DOTFILES/zsh/plugins/zsh-completions/src $fpath)
fpath=($HOME/src/zsh-completions/src $fpath)
# Should be called before compinit
zmodload zsh/complist
# Use hjlk in menu selection (during completion)
# Doesn't work well with interactive mode
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect '^xg' clear-screen
bindkey -M menuselect '^xi' vi-insert # Insert
bindkey -M menuselect '^xh' accept-and-hold # Hold
bindkey -M menuselect '^xn' accept-and-infer-next-history # Next
bindkey -M menuselect '^xu' undo # Undo
autoload -U compinit; compinit
_comp_options+=(globdots) # With hidden files
# Only work with the Zsh function vman
# See $DOTFILES/zsh/scripts.zsh
compdef vman="man"
# +---------+
# | Options |
# +---------+
# setopt GLOB_COMPLETE # Show autocompletion menu with globs
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
# +---------+
# | zstyles |
# +---------+
# Ztyle pattern
# :completion:<function>:<completer>:<command>:<argument>:<tag>
# Define completers
zstyle ':completion:*' completer _extensions _complete _approximate
# Use cache for commands using cache
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/.zcompcache"
# Complete the alias when _expand_alias is used as a function
zstyle ':completion:*' complete true
zle -C alias-expension complete-word _generic
bindkey '^Xa' alias-expension
zstyle ':completion:alias-expension:*' completer _expand_alias
# Use cache for commands which use it
# Allow you to select in a menu
zstyle ':completion:*' menu select
# Autocomplete options for cd instead of directory stack
zstyle ':completion:*' complete-options true
zstyle ':completion:*' file-sort modification
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
zstyle ':completion:*:*:*:*:descriptions' format '%F{blue}-- %D %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'
# Colors for files and directory
zstyle ':completion:*:*:*:*:default' list-colors ${(s.:.)LS_COLORS}
# Only display some tags for the command cd
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
# zstyle ':completion:*:complete:git:argument-1:' tag-order !aliases
# Required for completion to be in good groups (named after the tags)
zstyle ':completion:*' group-name ''
zstyle ':completion:*:*:-command-:*:*' group-order aliases builtins functions commands
# See ZSHCOMPWID "completion matching control"
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' keep-prefix true
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
## For kubernetes
# source $DOTFILES/zsh/plugins/kubectl-completion/_kubectl
# zstyle ':completion:*:*:kubectl:*' list-grouped false