summaryrefslogtreecommitdiff
path: root/plugins/1password/_opswd
diff options
context:
space:
mode:
authorAdam Pike <adam.pike@1password.com>2022-03-26 15:11:04 +0100
committerMarc Cornellà <hello@mcornella.com>2022-03-26 15:16:19 +0100
commitdbadfa0810c0be346b98c02cc802c33fa43bee11 (patch)
treec02594da735f7b9e3c13f7273d98ec0f557fdf62 /plugins/1password/_opswd
parenta64d9403775f45036daf3b66693c35df7bab3c53 (diff)
downloadzsh-dbadfa0810c0be346b98c02cc802c33fa43bee11.tar.gz
zsh-dbadfa0810c0be346b98c02cc802c33fa43bee11.tar.bz2
zsh-dbadfa0810c0be346b98c02cc802c33fa43bee11.zip
refactor(1password): support CLI 2 and soft-deprecate CLI 1 (#10787)
This change still supports CLI 1, but shows a deprecation warning on the first run of `opswd`. Support for CLI 1 shall be removed in the near future. Closes #10787 Co-authored-by: Marc Cornellà <hello@mcornella.com>
Diffstat (limited to 'plugins/1password/_opswd')
-rw-r--r--plugins/1password/_opswd12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/1password/_opswd b/plugins/1password/_opswd
index b92bf8fc8..dbc094f87 100644
--- a/plugins/1password/_opswd
+++ b/plugins/1password/_opswd
@@ -2,8 +2,18 @@
function _opswd() {
local -a services
- services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
+ services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
[[ -z "$services" ]] || compadd -a -- services
}
+# TODO: 2022-03-26: Remove support for op CLI 1
+autoload -Uz is-at-least
+is-at-least 2.0.0 $(op --version) || {
+ function _opswd() {
+ local -a services
+ services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
+ [[ -z "$services" ]] || compadd -a -- services
+ }
+}
+
_opswd "$@"