diff options
| -rw-r--r-- | zsh/functions/_op-ssh-add | 3 | ||||
| -rw-r--r-- | zsh/functions/op-ssh-add | 58 | ||||
| -rw-r--r-- | zsh/rc | 2 |
3 files changed, 1 insertions, 62 deletions
diff --git a/zsh/functions/_op-ssh-add b/zsh/functions/_op-ssh-add deleted file mode 100644 index 2c2183e..0000000 --- a/zsh/functions/_op-ssh-add +++ /dev/null @@ -1,3 +0,0 @@ -#compdef op-ssh-add=ssh-add - -_ssh $@ diff --git a/zsh/functions/op-ssh-add b/zsh/functions/op-ssh-add deleted file mode 100644 index 6bbdd13..0000000 --- a/zsh/functions/op-ssh-add +++ /dev/null @@ -1,58 +0,0 @@ -# -*- mode: sh -*- - -# op-ssh-add will add SSH keys to the agent, but will fetch the -# passphrase in 1Password rather than prompt you for it. -# -# 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. -# -# You must also have the 1Password CLI 2 installed. - -if [[ ${@[1]} =~ '-[DdKLlTXx]' ]]; then - command ssh-add $@ - return $? -fi - -local args=$@ fp prv pub -for prv (${@[-1]} ~/.ssh/id_{ecdsa,ed25519}{_sk,}); do - if [[ -f ${prv}.pub ]]; then - pub=${prv}.pub - fp=$(cut -d' ' -f2 <<< $(ssh-keygen -f ${pub} -l)) - if [[ ${prv} != ${@[-1]} ]]; then - args+=(${prv}) - fi - break - fi -done - -if [[ -z ${pub} ]]; then - command ssh-add $@ - return $? -fi - -local session=$(op signin --raw) -if [[ -z ${session} ]]; then - return 1 -fi - -zmodload zsh/zpty -zpty ssh command ssh-add ${args} - -_cleanup() { - zpty -d ssh - op signout --session $1 - trap - - unfunction _cleanup -} -trap "_cleanup ${session}" EXIT HUP INT TERM - -zpty -w ssh $(trap - - 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 @@ -10,7 +10,7 @@ done } -autoload -Uz compinit op-ssh-add zmv +autoload -Uz compinit zmv [[ ! -d ${XDG_CACHE_HOME}/zsh ]] && mkdir -p ${XDG_CACHE_HOME}/zsh zstyle ':completion:*' cache-path ${XDG_CACHE_HOME}/zsh/cache |
