mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-12-04 06:08:55 +01:00
feat(sprite): add completion plugin (#13703)
Co-authored-by: Robby Russell <robby@planetargon.com> Signed-off-by: Jonathan Stacks <jonstacks@users.noreply.github.com>
This commit is contained in:
1 parent
e6647fae62
commit
35902fc3a1
2 files changed
+37
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
# sprite plugin
|
||||||
|
|
||||||
|
This plugin adds completion for the [Sprites CLI](https://docs.sprites.dev/cli/installation) (`sprite`).
|
||||||
|
|
||||||
|
To use it, add `sprite` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... sprite)
|
||||||
|
```
|
||||||
|
|
||||||
|
This plugin does not add any aliases.
|
||||||
|
|
||||||
|
## Cache
|
||||||
|
|
||||||
|
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
||||||
|
loaded, which is usually when you start up a new terminal emulator.
|
||||||
|
|
||||||
|
The cache is stored at:
|
||||||
|
|
||||||
|
- `$ZSH_CACHE_DIR/completions/_sprite` completions script
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Autocompletion for sprite
|
||||||
|
if (( ! $+commands[sprite] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `sprite`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_sprite" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _sprite
|
||||||
|
_comps[sprite]=_sprite
|
||||||
|
fi
|
||||||
|
|
||||||
|
() {
|
||||||
|
local tmpfile="$ZSH_CACHE_DIR/completions/_sprite.$$.tmp"
|
||||||
|
sprite completion zsh >| "$tmpfile" 2>/dev/null && command mv -f "$tmpfile" "$ZSH_CACHE_DIR/completions/_sprite" || command rm -f "$tmpfile"
|
||||||
|
} &|
|
||||||
Reference in new issue
Block a user