[zsh] Add connect_ssh_agent to invoke ssh-agent anew or with pre-existing variables in ~/.ssh_agent_vars
This commit is contained in:
parent
9937af9f49
commit
bb47c6cc52
1 changed files with 12 additions and 0 deletions
12
zsh/func/connect_ssh_agent
Normal file
12
zsh/func/connect_ssh_agent
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
# Start SSH agent for password-less logins
|
||||
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
|
||||
if ! pgrep -u $USER ssh-agent 1>/dev/null; then
|
||||
eval $(ssh-agent -s > ~/.ssh_agent_vars)
|
||||
trap "kill $SSH_AGENT_PID" 0
|
||||
else
|
||||
eval $(cat ~/.ssh_agent_vars)
|
||||
fi
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue