summaryrefslogtreecommitdiff
path: root/oh-my-zsh/plugins/1password/_opswd
diff options
context:
space:
mode:
authorAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
committerAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
commitedc449275b6c04445f58b108ca0937a87c1e8430 (patch)
tree9fd484d58145b616f29a78857cc0b1c8b1c18f05 /oh-my-zsh/plugins/1password/_opswd
parent6f5424ca96c4221ef433f545642669e9c104d0ed (diff)
add zsh
Diffstat (limited to 'oh-my-zsh/plugins/1password/_opswd')
-rw-r--r--oh-my-zsh/plugins/1password/_opswd19
1 files changed, 19 insertions, 0 deletions
diff --git a/oh-my-zsh/plugins/1password/_opswd b/oh-my-zsh/plugins/1password/_opswd
new file mode 100644
index 0000000..dbc094f
--- /dev/null
+++ b/oh-my-zsh/plugins/1password/_opswd
@@ -0,0 +1,19 @@
+#compdef opswd
+
+function _opswd() {
+ local -a services
+ 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 "$@"