871d4b9816e6a8bdf809149c79f468d0fcb888db

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

Message

fix(1password)!: remove v1 support (#13507)

BREAKING CHANGE: `op` v1 support has been removed. Please migrate to v2
if you are affected by this change.

Diff

 1diff --git a/plugins/1password/_opswd b/plugins/1password/_opswd
 2index dbc094f87ec3a62959baf5ab77dfc10977e7dfa1..694df5cfab05acaef4399b772feefb087e7fb104 100644
 3--- a/plugins/1password/_opswd
 4+++ b/plugins/1password/_opswd
 5@@ -6,14 +6,4 @@ function _opswd() {
 6   [[ -z "$services" ]] || compadd -a -- services
 7 }
 8 
 9-# TODO: 2022-03-26: Remove support for op CLI 1
10-autoload -Uz is-at-least
11-is-at-least 2.0.0 $(op --version) || {
12-  function _opswd() {
13-    local -a services
14-    services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
15-    [[ -z "$services" ]] || compadd -a -- services
16-  }
17-}
18-
19 _opswd "$@"
20diff --git a/plugins/1password/opswd b/plugins/1password/opswd
21index 753de9f9917c2e5041c68ea62e47d55eb4c89468..9e09ae7358ad42ca849cefbc3d4f352965070f48 100644
22--- a/plugins/1password/opswd
23+++ b/plugins/1password/opswd
24@@ -46,45 +46,4 @@ function opswd() {
25   (sleep 20 && clipcopy </dev/null 2>/dev/null) &!
26 }
27 
28-# TODO: 2022-03-26: Remove support for op CLI 1
29-autoload -Uz is-at-least
30-is-at-least 2.0.0 $(op --version) || {
31-  print -ru2 ${(%):-"%F{yellow}opswd: usage with op version $(op --version) is deprecated. Upgrade to CLI 2 and reload zsh.
32-For instructions, see https://developer.1password.com/docs/cli/upgrade.%f"}
33-
34-  # opswd puts the password of the named service into the clipboard. If there's a
35-  # one time password, it will be copied into the clipboard after 10 seconds. The
36-  # clipboard is cleared after another 20 seconds.
37-  function opswd() {
38-    if [[ $# -lt 1 ]]; then
39-      echo "Usage: opswd <service>"
40-      return 1
41-    fi
42-
43-    local service=$1
44-
45-    # If not logged in, print error and return
46-    op list users > /dev/null || return
47-
48-    local password
49-    # Copy the password to the clipboard
50-    if ! password=$(op get item "$service" --fields password 2>/dev/null); then
51-      echo "error: could not obtain password for $service"
52-      return 1
53-    fi
54-
55-    echo -n "$password" | clipcopy
56-    echo "✔ password for $service copied to clipboard"
57-
58-    # If there's a one time password, copy it to the clipboard after 5 seconds
59-    local totp
60-    if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
61-      sleep 10 && echo -n "$totp" | clipcopy
62-      echo "✔ TOTP for $service copied to clipboard"
63-    fi
64-
65-    (sleep 20 && clipcopy </dev/null 2>/dev/null) &!
66-  }
67-}
68-
69 opswd "$@"