From 30db4a019fe7dccf296c36aa34b8b71b69d950bc Mon Sep 17 00:00:00 2001 From: George Ang Date: Wed, 21 Dec 2016 13:27:38 +0800 Subject: [PATCH] Auto load identities under macOS. --- modules/ssh/init.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index f632328d..f5ce1fd2 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -6,10 +6,16 @@ # # Return if requirements are not found. -if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then +if (( ! $+commands[ssh-agent] )); then return 1 fi +if [[ "$OSTYPE" == darwin* ]]; then + _ssh_add_cmd="ssh-add -A" +else + _ssh_add_cmd="ssh-add" +fi + # Set the path to the SSH directory. _ssh_dir="$HOME/.ssh" @@ -40,11 +46,11 @@ fi if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' if (( ${#_ssh_identities} > 0 )); then - ssh-add "$_ssh_dir/${^_ssh_identities[@]}" 2> /dev/null + ${(s: :)_ssh_add_cmd} "$_ssh_dir/${^_ssh_identities[@]}" 2> /dev/null else - ssh-add 2> /dev/null + ${(s: :)_ssh_add_cmd} 2> /dev/null fi fi # Clean up. -unset _ssh_{dir,identities} _ssh_agent_{env,sock} +unset _ssh_{dir,identities} _ssh_agent_{env,sock} _ssh_add_cmd