Repository navigation
Expand file tree
/
Copy pathdot_completions
More file actions
101 lines (86 loc) · 4.03 KB
/
Copy pathdot_completions
File metadata and controls
101 lines (86 loc) · 4.03 KB
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
local brew_share="${HOMEBREW_PREFIX:+${HOMEBREW_PREFIX}/share}"
typeset -g _comp_dumpfile="${HOME}/.cache/zsh/compdump"
# `brew shellenv` exports FPATH, so a nested shell inherits these entries and
# adds them again. zsh-completions goes first, as its caveats prescribe. bun's
# file belongs on fpath, because sourcing it before compinit runs a full
# uncached compinit.
typeset -gU FPATH fpath
fpath=(
${brew_share:+${brew_share}/zsh-completions}
${HOME}/.bun(N/)
$fpath
)
# compinit -C skips a freshness check that costs about 440 ms per shell, so two
# tests here decide when to rebuild the dump: its age, and the fpath list,
# because no age check notices an edit to that list. `^ms-0` drops a dump dated
# in the future, as in run:daily. Directory mtimes do not work, because plugins
# rewrite ~/.cache/oh-my-zsh/completions on every shell. [[ ]] never globs, so
# the age test assigns to an array.
[[ -d ${_comp_dumpfile:h} ]] || mkdir -p ${_comp_dumpfile:h}
local fpath_stamp="${_comp_dumpfile}.fpath"
local -a fresh=( ${_comp_dumpfile}(N.mh-24^ms-0) )
if (( ! ${#fresh} )) || [[ ! -f $fpath_stamp || "$fpath" != "$(<$fpath_stamp)" ]]; then
command rm -f -- "$_comp_dumpfile"
print -r -- "$fpath" >| "$fpath_stamp"
fi
zmodload zsh/complist
autoload -Uz compinit
compinit -C -d "$_comp_dumpfile"
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:descriptions' format $'%{\e[2m%}%d%{\e[0m%}'
unsetopt LIST_BEEP
if (( ${#COMPDEF_DEFERRED} )); then
local deferred
for deferred in "${COMPDEF_DEFERRED[@]}"; do
eval "compdef ${deferred}"
done
fi
unset COMPDEF_DEFERRED
_claude_accounts() {
(( CURRENT == 2 )) && compadd -- "${HOME}"/.claude-accounts/*(N/:t)
}
compdef _claude_accounts claude:as claude:chrome claude:remove
# Generating this spawns Node, so it is kept for a day. $SHELL is forced because
# yargs emits the bash flavor otherwise, and the header check rejects a
# truncated reply.
if cmd:exists ng; then
local ng_completion="${HOME}/.cache/zsh/ng-completion.zsh"
local -a ng_fresh=( ${ng_completion}(N.mh-24^ms-0) )
if (( ! ${#ng_fresh} )); then
if SHELL=/bin/zsh ng completion script >| "${ng_completion}.new" 2>/dev/null &&
[[ "$(head -n 1 "${ng_completion}.new")" == "#compdef ng" ]]; then
command mv -f "${ng_completion}.new" "$ng_completion"
else
# Stamp a failed attempt too, or a broken ng respawns Node before every
# prompt. An empty file fails the -s test below.
command rm -f "${ng_completion}.new"
command touch "$ng_completion"
fi
fi
[[ -s "$ng_completion" ]] && source "$ng_completion"
fi
# Every widget exists before the first prompt, Figxit's and Atuin's included, so
# one binding pass replaces the default rebind before every prompt
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
if [[ -n "$brew_share" ]]; then
[[ -f "${brew_share}/zsh-autosuggestions/zsh-autosuggestions.zsh" ]] \
&& source "${brew_share}/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
bindkey '^[[Z' reverse-menu-complete
bindkey -M menuselect '^[[Z' reverse-menu-complete
if [[ -n "$brew_share" ]]; then
[[ -f "${brew_share}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]] \
&& source "${brew_share}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
if [[ -f "${brew_share}/zsh-history-substring-search/zsh-history-substring-search.zsh" ]]; then
source "${brew_share}/zsh-history-substring-search/zsh-history-substring-search.zsh"
bindkey '^[[A' history-substring-search-up '^[OA' history-substring-search-up
bindkey '^[[B' history-substring-search-down '^[OB' history-substring-search-down
# Alt-Up and Alt-Down, which would otherwise type the tail of their sequence
bindkey '^[[1;3A' history-substring-search-up '^[^[[A' history-substring-search-up
bindkey '^[[1;3B' history-substring-search-down '^[^[[B' history-substring-search-down
fi
fi
# `local` outside a function is `typeset`, and this file is sourced
unset brew_share fpath_stamp fresh deferred ng_completion ng_fresh