1
0
Fork 0

Auto load identities under macOS.

pull/1242/head
George Ang 8 years ago
parent 4f19700919
commit 30db4a019f

@ -6,10 +6,16 @@
# #
# Return if requirements are not found. # Return if requirements are not found.
if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then if (( ! $+commands[ssh-agent] )); then
return 1 return 1
fi 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. # Set the path to the SSH directory.
_ssh_dir="$HOME/.ssh" _ssh_dir="$HOME/.ssh"
@ -40,11 +46,11 @@ fi
if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then
zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities' zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities'
if (( ${#_ssh_identities} > 0 )); then 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 else
ssh-add 2> /dev/null ${(s: :)_ssh_add_cmd} 2> /dev/null
fi fi
fi fi
# Clean up. # Clean up.
unset _ssh_{dir,identities} _ssh_agent_{env,sock} unset _ssh_{dir,identities} _ssh_agent_{env,sock} _ssh_add_cmd

Loading…
Cancel
Save