From 3db99de9990d5aeac7faeb0cd2b41bf0f69543e9 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Fri, 30 Nov 2012 20:34:06 -0800 Subject: [PATCH] [zshrc] only run keychain for interactive sessions --- zsh/zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zsh/zshrc b/zsh/zshrc index 0e53dcd..825534d 100755 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -6,6 +6,9 @@ function mac() { [[ "$uname" = "Darwin" ]] } # check if a command is available function command_exists() { which "$1" >/dev/null 2>/dev/null } +# check if this is an interactive session +# (tests if stdout is a tty) +function is_interactive() { [ -t 1 ] } # 1. Environment Vars # =================== @@ -329,7 +332,7 @@ compinit # 10. SSH Keychain # ================ -if command_exists keychain && [[ -d ~/.ssh ]]; then +if is_interactive && command_exists keychain && [[ -d ~/.ssh ]]; then keychain --nogui ~/.ssh/id_rsa*~*.pub(N) KEYCHAINFILE="$HOME/.keychain/$(hostname)-sh" if [[ -f $KEYCHAINFILE ]]; then