about summary refs log tree commit diff
path: root/profile/.profile.d/gnupg.sh
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>1970-01-01 03:00:00 +0300
committerAzat Bahawi <azat@bahawi.net>2022-09-20 11:51:54 +0300
commit38bab29776950ac2364ed64195b89887717c33de (patch)
treeedaaf366a55dbe96d268019124536bc504c64e87 /profile/.profile.d/gnupg.sh
chore: init HEAD master
Diffstat (limited to 'profile/.profile.d/gnupg.sh')
-rw-r--r--profile/.profile.d/gnupg.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/profile/.profile.d/gnupg.sh b/profile/.profile.d/gnupg.sh
new file mode 100644
index 0000000..d5d531f
--- /dev/null
+++ b/profile/.profile.d/gnupg.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if command -v gpg >/dev/null 2>&1; then
+	GPG_TTY="$(tty)"
+	export GPG_TTY
+
+	if command -v ssh >/dev/null 2>&1 &&
+		command -v gpgconf >/dev/null 2>&1; then
+		unset SSH_AGENT_PID
+		if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne "${$}" ]; then
+			SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
+			export SSH_AUTH_SOCK
+		fi
+	fi
+
+	if command -v gpg-connect-agent >/dev/null 2>&1 &&
+		[ "${TERM}" != "linux" ]; then
+		gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
+	fi
+fi

Consider giving Nix/NixOS a try! <3