aboutsummaryrefslogtreecommitdiff
path: root/files/.zsh/rc/S40_completion
blob: 195c16b0fab022a3ce9bcf436dd74ca50bd48763 (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
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

compdef fdfind=fd

# Completing generic gnu commands
# https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
compdef _gnu_generic lshw df duplicity tldr
compdef _gnu_generic -p 'pg_*'

__load_completion_if_exists() {
  [[ -f "$1" ]] && source "$1"
}

__load_completion_if_exists /etc/bash_completion.d/youtube-dl.bash-completion
__load_completion_if_exists /usr/share/zsh/vendor-completions/_git-extras

unset -f __load_completion_if_exists

# vim: et ft=zsh fdm=marker :