-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy path.completions
79 lines (64 loc) · 2.16 KB
/
.completions
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
#!/usr/bin/env zsh
# `.completions` handles all custom auto-completions.
# Enable hidden files on completion:
setopt globdots
# Uncomment to set `CTRL-k` to show debug info:
# Usage: `your command <CTRL-k>`
# bindkey '^k' _complete_help
# === fzf-tab ===
# https://github.com/Aloxaf/fzf-tab
# enable hidden files on completion
zstyle ':completion:*' special-dirs true
# hide parents
zstyle ':completion:*' ignored-patterns '.|..|.DS_Store|**/.|**/..|**/.DS_Store|**/.git'
# hide `..` and `.` from file menu
zstyle ':completion:*' ignore-parents 'parent pwd directory'
# force zsh not to show completion menu,
# which allows fzf-tab to capture the unambiguous prefix
zstyle ':completion:*' menu no
# switch groups using `[` and `]`
zstyle ':fzf-tab:*' switch-group '[' ']'
# use the same layout as others and respect my default
local fzf_flags
zstyle -a ':fzf-tab:*' fzf-flags fzf_flags
fzf_flags=( "${fzf_flags[@]}" '--layout=reverse-list' )
zstyle ':fzf-tab:*' fzf-flags $fzf_flags
# Tools to autocomplete:
# ----------------------
# Big sources of inspiration:
# - https://github.com/Freed-Wu/fzf-tab-source
# - https://github.com/DanielFGray/fzf-scripts
# complete `fzf`
compdef _gnu_generic fzf
# complete `ls` / `cat` / etc
zstyle ':fzf-tab:complete:(\\|*/|)(ls|gls|bat|cat|cd|rm|cp|mv|ln|nano|code|open|tree|source):*' \
fzf-preview \
'_fzf_complete_realpath "$realpath"'
# complete `make`
zstyle ':fzf-tab:complete:(\\|*/|)make:*' fzf-preview \
'case "$group" in
"[make target]")
make -n "$word" | _fzf_complete_realpath
;;
"[make variable]")
make -pq | ag "^$word =" | _fzf_complete_realpath
;;
"[file]")
_fzf_complete_realpath "$realpath"
;;
esac'
# complete `killall`
zstyle ':completion:*:*:killall:*:*' command 'ps -u "$USERNAME" -o comm'
zstyle ':fzf-tab:complete:(\\|*/|)killall:*' fzf-preview \
'ps aux | ag "$word" | _fzf_complete_realpath'
# complete `zoxide`
_z () {
# I have a custom completion, because I like `z NAME<TAB>`
# and not `z NAME<SPACE><TAB>`
local args
args="$(zoxide query -a -l)"
_arguments "1:paths:($args)"
}
compdef _z z
zstyle ':fzf-tab:complete:(\\|*/|)z:*' fzf-preview \
'_fzf_complete_realpath "$word"'