summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-03-19 18:45:33 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2022-03-19 18:45:33 +0000
commite0cdf8a46d8fc8aa3647e70a327f9d19f88a68ee (patch)
tree7ba490641dab87665de49eb5476cc5e026e44e5b
parent4334c3b98b4d8f4c5de96a6d5e394941aa255d73 (diff)
zsh/op-ssh-add: Support 1Password CLI 2
-rw-r--r--zsh/functions/op-ssh-add16
1 files changed, 8 insertions, 8 deletions
diff --git a/zsh/functions/op-ssh-add b/zsh/functions/op-ssh-add
index 4644349..6bbdd13 100644
--- a/zsh/functions/op-ssh-add
+++ b/zsh/functions/op-ssh-add
@@ -6,10 +6,10 @@
# To be found, keys must have the following three things:
#
# 1. Have the password field set to the passphrase of the key,
-# 2. Have an `SSH' tag set, and
-# 3. Have a `fingerprint' field set to the fingerprint of the key.
+# 2. Have an ‘SSH’ tag set, and
+# 3. Have a ‘fingerprint’ field set to the fingerprint of the key.
#
-# You must also have the 1Password CLI tool (op) and jq installed.
+# You must also have the 1Password CLI 2 installed.
if [[ ${@[1]} =~ '-[DdKLlTXx]' ]]; then
command ssh-add $@
@@ -50,9 +50,9 @@ _cleanup() {
trap "_cleanup ${session}" EXIT HUP INT TERM
zpty -w ssh $(trap -
- op list items --session ${session} --tags SSH \
- | op get item \
- --fields fingerprint,password \
- --session ${session} - \
- | jq -j "select(.fingerprint == \"${fp}\") | .password")
+ op item list --format json --session ${session} --tags SSH \
+ | op item get \
+ --fields fingerprint,password \
+ --session ${session} - \
+ | grep ${fp} | cut -d, -f2)
zpty -r ssh