blob: 84a9e6a0e9665fc3faea73c16afcdf8d385a4d33 (
plain) (
blame)
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
|
zstyle ':completion:*' add-space true
zstyle ':completion:*' completer _expand _complete _match _prefix _approximate _list
zstyle ':completion:*' menu select=1
zstyle ':completion:*' file-sort name
zstyle ':completion:*' list-colots ${(s.:.)ZLS_COLORS}
zstyle ':completion:*' menu select
zstyle ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
# {{{ Formats
zstyle ':completion:*' group 1
zstyle ':completion:*' format '%B---- %d%b'
zstyle ':completion:*:corrections' format '%B---- %d (errors %e)%b'
zstyle ':completion:*:descriptions' format '%B---- %d%b'
zstyle ':completion:*:messages' format '%B%U---- d%u%b'
zstyle ':completion:*:warnings' format "%B$fg[red]%}---- no match for: $fg[white]%d%b"
zstyle ':completion:*' group-name ''
# }}}
# {{{ Kill
zstyle ':completion:*:processes' command 'ps -au$USER -o pid,time,cmd | grep -v "ps -au$USER -o pid,time,cmd"'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)[ 0-9:]##([^ ]#)*=01;30=01;31=01;38'
# }}}
# {{{ Host and users
hosts=($( ( \
( [ -r ~/.ssh/config ] && awk '/^host +[a-z]/ { print $2 }' ~/.ssh/config) ; \
( [ -r ~/.ssh/known_hosts ] && awk '{print $1}' ~/.ssh/known_hosts | tr , '\n') \
) | sort -u))
zstyle ':completion:*' hosts $hosts
zstyle ':completion:*:hosts' list-colors '=(#b)(*)(bobov.name)=01;30=01;31' '=[^.]#=01;31'
users=(root anton)
zstyle ':completion:*' users $users
# }}}
# Ignore for vim
zstyle ':completion:*:*:vi(m|):*:*files' ignored-patterns '*?.(aux|dvi|ps|pdf|bbl|toc|lot|lof|o|cm?|class|py[oc])'
# Ledger completion like hledger
compdef ledger=hledger
# Completing generic gnu commands
# https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
compdef _gnu_generic lshw df duplicity
compdef _gnu_generic -p 'pg_*'
compdef _command tldr
__load_completion_if_exists() {
[[ -f "$1" ]] && source "$1"
}
__load_or_generate() {
if ! command -v "$1" >/dev/null ; then
return
fi
local target_file="$HOME/.zsh/zsh-completions-cached/_$1"
if [ ! -f "$target_file" ] ; then
local generate_command="$2"
eval "$generate_command" > "$target_file"
fi
}
__load_completion_if_exists /etc/bash_completion.d/youtube-dl.bash-completion
__load_completion_if_exists /usr/share/zsh/vendor-completions/_git-extras
__load_or_generate kubectl "kubectl completion zsh"
__load_or_generate helm "helm completion zsh"
__load_or_generate yq "yq shell-completion zsh"
__load_or_generate fdfind 'curl -sL "https://raw.githubusercontent.com/sharkdp/fd/master/contrib/completion/_fd"'
__load_or_generate restic 'restic generate --zsh-completion /dev/stdout'
__load_or_generate docker 'curl -sL "https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker"'
__load_or_generate docker-compose 'curl -sL "https://raw.githubusercontent.com/docker/compose/1.28.x/contrib/completion/zsh/_docker-compose"'
__load_or_generate watson 'curl -sL "https://raw.githubusercontent.com/TailorDev/Watson/master/watson.zsh-completion"'
__load_or_generate cheat 'curl -sL "https://raw.githubusercontent.com/cheat/cheat/master/scripts/cheat.zsh"'
compdef fdfind=fd
unset -f __load_completion_if_exists __load_or_generate
# vim: et ft=zsh fdm=marker :
|