543d6c0db197b624f8cf8be296fa2e5d37d3e6c2

Author
Carlo Sala <carlosalag@protonmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(rbw): add completion for `rbw` Bitwarden client (#10346)

Diff

 1diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt
 2index 65215c6c3a31547d487b4cfa23218658c6e3bfb8..5c5a04ff1197de72d080c6b26655fa0c0422a09e 100644
 3--- a/.github/actions/spelling/expect.txt
 4+++ b/.github/actions/spelling/expect.txt
 5@@ -22,8 +22,8 @@ acr
 6 acroread
 7 acs
 8 acsc
 9-acss
10 acsp
11+acss
12 actionformats
13 Adamantium
14 adb
15@@ -312,6 +312,7 @@ bisd
16 bitboxer
17 bitbucket
18 bitswap
19+bitwarden
20 blkio
21 blockprofile
22 blockprofilerate
23@@ -3119,6 +3120,7 @@ rbenv
24 rbenvdirs
25 rbfu
26 RBUFFER
27+rbw
28 rcfile
29 Rchive
30 rcs
31@@ -4442,8 +4444,8 @@ zrr
32 zrs
33 zscore
34 zse
35-zsh'ed
36 zsh
37+zsh'ed
38 zshaddhistory
39 zshcmd
40 zshcommands
41diff --git a/plugins/rbw/README.md b/plugins/rbw/README.md
42new file mode 100644
43index 0000000000000000000000000000000000000000..87d073d24c25fe2d457dd6c8db6ab68b54d76720
44--- /dev/null
45+++ b/plugins/rbw/README.md
46@@ -0,0 +1,12 @@
47+# Bitwarden (unofficial) CLI plugin
48+
49+This plugin adds completion for [rbw](https://github.com/doy/rbw), an unofficial
50+CLI for [Bitwarden](https://bitwarden.com).
51+
52+To use it, add `rbw` to the plugins array in your zshrc file:
53+
54+```zsh
55+plugins=(... rbw)
56+```
57+
58+This plugin does not add any aliases.
59diff --git a/plugins/rbw/rbw.plugin.zsh b/plugins/rbw/rbw.plugin.zsh
60new file mode 100644
61index 0000000000000000000000000000000000000000..3825be7a64ee717ceea085ea614627902a58f59a
62--- /dev/null
63+++ b/plugins/rbw/rbw.plugin.zsh
64@@ -0,0 +1,19 @@
65+if (( ! $+commands[rbw] )); then
66+  return
67+fi
68+
69+# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
70+# Add completions folder in $ZSH_CACHE_DIR
71+command mkdir -p "$ZSH_CACHE_DIR/completions"
72+(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
73+
74+
75+# If the completion file doesn't exist yet, we need to autoload it and
76+# bind it to `rbw`. Otherwise, compinit will have already done that.
77+if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then
78+  declare -A _comps
79+  autoload -Uz _rbw
80+  _comps[rbw]=_rbw
81+fi
82+
83+rbw gen-completions zsh >| "$ZSH_CACHE_DIR/completions/_rbw" &|