summaryrefslogtreecommitdiff
path: root/plugins/bun
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
committerTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
commit4d908094fdc2a0c0e9a0a072eba213fab7adef43 (patch)
tree7c17e70bcdeebbe96c84d849bdf17882007480d8 /plugins/bun
parent4b0bbc0b263a150eb9a9b59f196914629be06a9b (diff)
parent632ed413a9ce62747ded83d7736491b081be4b49 (diff)
downloadzsh-master.tar.gz
zsh-master.tar.bz2
zsh-master.zip
Merge remote-tracking branch 'github/master'HEADmaster
Diffstat (limited to 'plugins/bun')
-rw-r--r--plugins/bun/README.md20
-rw-r--r--plugins/bun/bun.plugin.zsh14
2 files changed, 34 insertions, 0 deletions
diff --git a/plugins/bun/README.md b/plugins/bun/README.md
new file mode 100644
index 000000000..5a312370f
--- /dev/null
+++ b/plugins/bun/README.md
@@ -0,0 +1,20 @@
+# Bun Plugin
+
+This plugin sets up completion for [Bun](https://bun.sh).
+
+To use it, add `bun` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... bun)
+```
+
+This plugin does not add any aliases.
+
+## Cache
+
+This plugin caches the completion script and is automatically updated 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/_bun_` completions script
diff --git a/plugins/bun/bun.plugin.zsh b/plugins/bun/bun.plugin.zsh
new file mode 100644
index 000000000..9924faa84
--- /dev/null
+++ b/plugins/bun/bun.plugin.zsh
@@ -0,0 +1,14 @@
+# If Bun is not found, don't do the rest of the script
+if (( ! $+commands[bun] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `bun`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _bun
+ _comps[bun]=_bun
+fi
+
+bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|