diff options
Diffstat (limited to '_zsh/80-gpg.zsh')
-rw-r--r-- | _zsh/80-gpg.zsh | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/_zsh/80-gpg.zsh b/_zsh/80-gpg.zsh index 80d1ecc..d72b699 100644 --- a/_zsh/80-gpg.zsh +++ b/_zsh/80-gpg.zsh @@ -15,6 +15,8 @@ if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" fi +# Let pinentry know which console to display in for `ssh-agent'. +# # Since the 'ssh-agent' protocol does not contain a mechanism for telling # the agent on which terminal/display it is running, gpg-agent's # ssh-support can just use the TTY or X display when `gpg-agent' has been @@ -31,7 +33,36 @@ fi # https://www.gnupg.org/documentation/manuals/gnupg/Common-Problems.html # * `gpg-agent(1)': option `--enable-ssh-support' # -gpg-connect-agent updatestartuptty /bye >/dev/null +update-gpg-tty() { + gpg-connect-agent updatestartuptty /bye >/dev/null +} + +update-pinentry-app() { + echo "term" > ${XDG_RUNTIME_DIR}/pinentry-app +} + +# Hook the above functions to be exec'ed before every command execuation +# +# Credit: http://blog.mrloop.com/workflow/2017/02/09/pin-entry.html +# +autoload -U add-zsh-hook +zsh-preexec() { + update-gpg-tty + update-pinentry-app +} +add-zsh-hook preexec zsh-preexec + + +# Delete all identities from the `gpg-agent', which is similar to +# `ssh-add -D`. +# +# Credit: http://blog.mrloop.com/workflow/2017/02/09/pin-entry.html +# +ssh-delete() { + grep -o '^[A-Z0-9]*' ${HOME}/.gnupg/sshcontrol | \ + xargs -I'%' rm ${HOME}/.gnupg/private-keys-v1.d/'%'.key + echo "" > ${HOME}/.gnupg/sshcontrol +} # vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: # |