[zshrc] only run keychain for interactive sessions
This commit is contained in:
parent
0d88ee278a
commit
3db99de999
1 changed files with 4 additions and 1 deletions
|
|
@ -6,6 +6,9 @@ function mac() { [[ "$uname" = "Darwin" ]] }
|
||||||
# check if a command is available
|
# check if a command is available
|
||||||
function command_exists() { which "$1" >/dev/null 2>/dev/null }
|
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
|
# 1. Environment Vars
|
||||||
# ===================
|
# ===================
|
||||||
|
|
@ -329,7 +332,7 @@ compinit
|
||||||
|
|
||||||
# 10. SSH Keychain
|
# 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)
|
keychain --nogui ~/.ssh/id_rsa*~*.pub(N)
|
||||||
KEYCHAINFILE="$HOME/.keychain/$(hostname)-sh"
|
KEYCHAINFILE="$HOME/.keychain/$(hostname)-sh"
|
||||||
if [[ -f $KEYCHAINFILE ]]; then
|
if [[ -f $KEYCHAINFILE ]]; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue