From 2736d11dd320b64c9cdd77bcaecd15756b73d89d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 16 Oct 2013 17:44:20 +1300 Subject: Move TTY/GPG_TTY exports into profile --- .gitignore | 1 + bash/bashrc.d/keychain.bash | 6 ++++++ sh/profile.d/keychain.sh | 7 +++++++ 3 files changed, 14 insertions(+) create mode 100644 bash/bashrc.d/keychain.bash 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 -- cgit v1.2.3