first commit
This commit is contained in:
commit
0610f4aeab
130 changed files with 9897 additions and 0 deletions
107
fn/-z4h-compinit
Normal file
107
fn/-z4h-compinit
Normal file
|
@ -0,0 +1,107 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
eval "$_z4h_opt"
|
||||
|
||||
if [[ -v _z4h_compinit_fd ]]; then
|
||||
zle -F $_z4h_compinit_fd
|
||||
exec {_z4h_compinit_fd}>&-
|
||||
unset _z4h_compinit_fd
|
||||
fi
|
||||
|
||||
unfunction compdef
|
||||
|
||||
local -aU editors=(
|
||||
vi vim nvim emacs nano gedit code kak kate mcedit joe $EDITOR $VISUAL
|
||||
bat cat less more $PAGER)
|
||||
zstyle ':completion:*:*:('${(j:|:)editors}'):*:*' ignored-patterns '*.zwc'
|
||||
|
||||
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
|
||||
|
||||
(( _z4h_use[zsh-completions] )) &&
|
||||
[[ -d $Z4H/zsh-completions/src ]] &&
|
||||
fpath+=($Z4H/zsh-completions/src)
|
||||
(( _z4h_use[systemd] )) &&
|
||||
[[ -e $Z4H/systemd/shell-completion/zsh/_systemctl && -z ${^fpath}/_systemctl(#qN) ]] &&
|
||||
fpath+=($Z4H/systemd/shell-completion/zsh)
|
||||
|
||||
if (( !_z4h_dangerous_root )) && zstyle -t ':completion::complete:' use-cache; then
|
||||
local cache
|
||||
zstyle -s ':completion::complete:' cache-path cache
|
||||
: ${cache:=${ZDOTDIR:-~}/.zcompcache}
|
||||
if [[ ! -e $cache ]]; then
|
||||
zf_mkdir -m 0700 -p -- $cache
|
||||
fi
|
||||
fi
|
||||
|
||||
local dump
|
||||
zstyle -s ':z4h:compinit' dump-path dump
|
||||
: ${dump:=$Z4H/cache/zcompdump-$EUID-$ZSH_VERSION}
|
||||
|
||||
local -a stat files=(${^fpath}/^([^_]*|*~|*.zwc)(-.N))
|
||||
(( ! $#files )) || zstat -A stat +mtime -- $files
|
||||
local real_sig=($ZSH_VERSION $ZSH_PATCHLEVEL $files $stat)
|
||||
real_sig='# '${(V)${(pj:\0:)real_sig}}$'\n'
|
||||
|
||||
local sig
|
||||
if [[ -r $dump ]] &&
|
||||
sysread -s $#real_sig sig <$dump &&
|
||||
[[ $sig == $real_sig && -r $dump.zwc ]] &&
|
||||
zstat -A stat +mtime -- $dump $dump.zwc &&
|
||||
(( stat[2] == stat[1] + 1 )); then
|
||||
-z4h-compinit-impl -C -d $dump
|
||||
else
|
||||
local tmp=$Z4H/tmp/zcompdump.$sysparams[pid]
|
||||
zf_rm -f -- $dump $dump.zwc $tmp $tmp.2
|
||||
-z4h-compinit-impl -C -d $tmp
|
||||
{ print -rn -- $real_sig; <$tmp } >$tmp.2
|
||||
zf_rm -f -- $tmp
|
||||
zf_mv -- $tmp.2 $dump
|
||||
-z4h-compile $dump
|
||||
fi
|
||||
|
||||
# Replay compdef calls.
|
||||
local args
|
||||
for args in $_z4h_compdef; do
|
||||
compdef "${(@0)args}"
|
||||
done
|
||||
unset _z4h_compdef
|
||||
|
||||
local cmd
|
||||
for cmd in helm kitty kubectl oc; do
|
||||
# Homebrew ships broken completions for kubectl, so we use our own even
|
||||
# if _comps[kubectl] is set.
|
||||
#
|
||||
# TODO: what about the rest of them in the list? Move them below?
|
||||
[[ -v commands[$cmd] ]] && compdef -- -z4h-complete-$cmd $cmd
|
||||
done
|
||||
|
||||
for cmd in cargo bw gh rustup; do
|
||||
if [[ -v commands[$cmd] && ! -v _comps[$cmd] ]]; then
|
||||
compdef -- -z4h-complete-$cmd $cmd
|
||||
fi
|
||||
done
|
||||
|
||||
for cmd in terraform vault packer; do
|
||||
if [[ -v commands[$cmd] && ! -v _comps[$cmd] ]]; then
|
||||
complete -o nospace -C =$cmd $cmd
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -v commands[aws_completer] && ! -v _comps[aws] ]]; then
|
||||
complete -C =aws_completer aws
|
||||
fi
|
||||
|
||||
if [[ -v commands[gcloud] && ! -v _comps[gcloud] ]]; then
|
||||
local dirs=(
|
||||
${HOMEBREW_PREFIX:+$HOMEBREW_PREFIX/share/google-cloud-sdk}
|
||||
~/google-cloud-sdk
|
||||
/usr/share/google-cloud-sdk
|
||||
/snap/google-cloud-sdk/current
|
||||
/snap/google-cloud-cli/current
|
||||
/usr/lib/google-cloud-sdk
|
||||
/usr/lib64/google-cloud-sdk
|
||||
/opt/google-cloud-sdk
|
||||
/opt/local/libexec/google-cloud-sdk
|
||||
)
|
||||
source -- $^dirs/completion.zsh.inc(-.Ne'<[[ -r ${REPLY:a} ]]>') /dev/null
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue