summaryrefslogtreecommitdiff
path: root/.config/zsh/completion.zsh
blob: baa0bc51075343e4c224830e408993e0ca3ec259 (plain)
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
# From https://wiki.archlinux.org/index.php/Zsh

### Keep the space after completion for some characters in zsh
#from https://unix.stackexchange.com/a/174641
ZLE_SPACE_SUFFIX_CHARS=$'|&'

### Handle command not found
if [ -e /usr/share/doc/pkgfile/command-not-found.zsh ]; then
	source /usr/share/doc/pkgfile/command-not-found.zsh
fi

### For autocompletion with an arrow-key driven interface
zstyle ':completion:*' menu select

### For autocompletion of command line switches for aliases
setopt complete_aliases

### For enabling autocompletion of privileged environments in privileged commands
zstyle ':completion::complete:*' gain-privileges 1

### Use cache
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.cache/zsh/cache

### Prevent CVS files/directories from being completed
zstyle ':completion:*:(all-|)files' ignored-patterns '(|*/)CVS'
zstyle ':completion:*:cd:*' ignored-patterns '(*/)#CVS'

### The number of errors allowed by _approximate to increase with the length of
### what you have typed so far
zstyle -e ':completion:*:approximate:*' \
	max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'

### Ignore completion functions for commands you don't have
zstyle ':completion:*:functions' ignored-patterns '_*'

### With helper functions
xdvi() { command xdvi ${*:-*.dvi(om[1])} }

### you can avoid having to complete at all in many cases, but if you do, you
### might want to fall into menu selection immediately andto have the words
### sorted by time:
zstyle ':completion:*:*:xdvi:*' menu yes select
zstyle ':completion:*:*:xdvi:*' file-sort time

### Completing process IDs with menu selection
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*'   force-list always
zstyle ':completion:*:processes' command 'ps -A -o pid,user,comm -w -w'

### If you end up using a directory as argument, this will remove the trailing slash
zstyle ':completion:*' squeeze-slashes true

### cd will never select the parent directory
zstyle ':completion:*:cd:*' ignore-parents parent pwd

### cd without cd
setopt auto_cd

### Complete from middle of filename
#zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*'
setopt complete_in_word

### auto rehash
zstyle ':completion:*' rehash true

### add colors
zstyle ':completion:*' menu select list-colors ${(s.:.)LS_COLORS}

### completion and prompt init
autoload -Uz compinit colors vcs_info
compinit