mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-28 03:13:03 +01:00
feat(fizzy): add completion plugin (#14297)
This commit is contained in:
1 parent
32726ad0a5
commit
387dfe0bfb
2 files changed
+42
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# Fizzy CLI plugin
|
||||
|
||||
This plugin adds completion for the [Fizzy CLI (fizzy)](https://github.com/basecamp/fizzy-cli).
|
||||
|
||||
To use it, add `fizzy` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fizzy)
|
||||
```
|
||||
|
||||
This plugin does not add any aliases.
|
||||
|
||||
## Cache
|
||||
|
||||
This plugin caches the completion script and automatically updates it when the
|
||||
plugin is loaded, which is usually when you start a new terminal emulator.
|
||||
|
||||
The cache is stored at `$ZSH_CACHE_DIR/completions/_fizzy`.
|
||||
@@ -0,0 +1,24 @@
|
||||
# Autocompletion for the Fizzy CLI (fizzy).
|
||||
if (( ! $+commands[fizzy] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion isn't registered yet, autoload it and bind it to `fizzy`.
|
||||
# Otherwise, compinit will have already done that from the cache.
|
||||
if [[ -z ${_comps[fizzy]-} ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _fizzy
|
||||
_comps[fizzy]=_fizzy
|
||||
fi
|
||||
|
||||
zmodload -F zsh/files b:zf_mv || return
|
||||
() {
|
||||
local cache_file="$ZSH_CACHE_DIR/completions/_fizzy"
|
||||
local temp_file
|
||||
temp_file=$(mktemp "$ZSH_CACHE_DIR/completions/._fizzy.XXXXXXXX") || return
|
||||
if command fizzy completion zsh >| "$temp_file" && [[ -s "$temp_file" ]] &&
|
||||
zf_mv -f -- "$temp_file" "$cache_file"; then
|
||||
return
|
||||
fi
|
||||
rm -f -- "$temp_file"
|
||||
} &|
|
||||
Reference in new issue
Block a user