以zsh為例:
vi ~/.zshrc
# 增加內容
source /tmp/my-ssh-agent.env
if ! pgrep ssh-agent | grep -q $SSH_AGENT_PID ; then
eval "$(ssh-agent -s)" > /dev/null
ssh-add ~/.ssh/xx.key > /dev/null 2>&1
ssh-add ~/.ssh/xx.key > /dev/null 2>1
env | grep -e SSH_AGENT_PID -e SSH_AUTH_SOCK > /tmp/my-ssh-agent.env
fi