summary refs log tree commit diff stats
path: root/zsh
diff options
context:
space:
mode:
authorAlan Pearce2017-08-18 21:23:35 +0200
committerAlan Pearce2017-08-18 21:23:53 +0200
commitaaaa3a1de82245f2a7b79475182eca113a2dfab2 (patch)
treeb2da2c509d819fda250e52613c5ce96e9cc18737 /zsh
parenta0c9b7633b0d4382e3681109d5011feae0e8bab3 (diff)
downloaddotfiles-aaaa3a1de82245f2a7b79475182eca113a2dfab2.tar.lz
dotfiles-aaaa3a1de82245f2a7b79475182eca113a2dfab2.tar.zst
dotfiles-aaaa3a1de82245f2a7b79475182eca113a2dfab2.zip
Configure GPG (version 2.1)
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.config/zsh/.zshrc18
1 files changed, 17 insertions, 1 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc
index 818cdf5..b7a20b9 100644
--- a/zsh/.config/zsh/.zshrc
+++ b/zsh/.config/zsh/.zshrc
@@ -106,7 +106,18 @@ bindkey '\e ' hist-complete
 zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
 zstyle ':completion:*' completer _expand _complete _match
 
-if [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]]
+if [[ -n $commands[gpg-connect-agent] ]]
+then
+  # When using SSH support, use the current TTY for passphrase prompts
+  gpg-connect-agent updatestartuptty /bye > /dev/null
+
+  # Point the SSH_AUTH_SOCK to the one handled by gpg-agent
+  if [ -S $(gpgconf --list-dirs agent-ssh-socket) ]; then
+    export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
+  else
+    echo "$(gpgconf --list-dirs agent-ssh-socket) doesn't exist. Is gpg-agent running ?"
+  fi
+elif [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]]
 then
   eval $(ssh-agent)
 fi
@@ -167,6 +178,11 @@ then
   alias gh=hub
 fi
 
+if [[ -n $commands[gpg2] && -z $commands[gpg] ]]
+then
+  alias gpg=gpg2
+fi
+
 if [[ -n $commands[lunchy] ]]
 then
   LUNCHY_DIR=$(dirname $(gem which lunchy))/../extras