--- /dev/null
+pinentry-program /usr/bin/pinentry-curses
+default-cache-ttl 3600
 
--- /dev/null
+if [ $EUID -ne 0 ] ; then
+    envfile="$HOME/.gnupg/gpg-agent.env"
+    if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
+        eval "$(cat "$envfile")"
+    else
+        eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
+    fi
+    export GPG_AGENT_INFO  # the env file does not contain the export statement
+    export SSH_AUTH_SOCK   # enable gpg-agent for ssh
+fi
 
 cp -if `pwd`/muttrc ~/.mutt/muttrc || true
 cp -if `pwd`/msmtp ~/.mutt/msmtp || true
 cp -if `pwd`/offlineimaprc ~/.mutt/offlineimaprc || true
+cp -if `pwd`/gpg-agent.conf ~/.gnupg/gpg-agent.conf || true
 sudo cp -if `pwd`/sudo/mpd.conf /etc/mpd.conf || true
 sudo cp -if `pwd`/sudo/settings.json /etc/transmission-daemon/settings.json || true
+sudo cp -if `pwd`/gpg-agent.sh /etc/profile.d/gpg-agent.sh || true
 
 if [ "$1" = "-x" ]
 then