aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--bash/bashrc.d/keychain.bash6
-rw-r--r--sh/profile.d/keychain.sh7
3 files changed, 14 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 37fa884a..47efcb50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ bash/bashrc.d/*
!bash/bashrc.d/ftp.bash
!bash/bashrc.d/grep.bash
!bash/bashrc.d/gnupg.bash
+!bash/bashrc.d/keychain.bash
!bash/bashrc.d/ls.bash
!bash/bashrc.d/mysql.bash
!bash/bashrc.d/options.bash
diff --git a/bash/bashrc.d/keychain.bash b/bash/bashrc.d/keychain.bash
new file mode 100644
index 00000000..2cb1093a
--- /dev/null
+++ b/bash/bashrc.d/keychain.bash
@@ -0,0 +1,6 @@
+# If TTY/GPG_TTY are set, update them
+if [[ -n $TTY || -n $GPG_TTY ]]; then
+ TTY=$(tty)
+ GPG_TTY=$TTY
+fi
+
diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh
index 08a34d86..ae7aa95a 100644
--- a/sh/profile.d/keychain.sh
+++ b/sh/profile.d/keychain.sh
@@ -8,5 +8,12 @@ fi
if command -v keychain >/dev/null 2>&1; then
eval "$(TERM=${TERM:-ansi} keychain \
--eval --ignore-missing --quiet id_dsa id_rsa id_ecsda)"
+
+ # Set and export TTY/GPG_TTY for interactive shells
+ if [ -t 0 ]; then
+ TTY=$(tty)
+ GPG_TTY=$TTY
+ export TTY GPG_TTY
+ fi
fi