Renamed ssh-agent plugin keychain.

This commit is contained in:
Simon Gomizelj 2011-12-01 09:14:47 -05:00
commit 134a262d65
2 changed files with 37 additions and 33 deletions

View file

@ -0,0 +1,37 @@
local ssh_env=$HOME/.ssh/environment-$HOST
function start_agent()
{
local -a identities
# start ssh-agent and setup environment
ssh-agent | sed 's/^echo/#echo/' >${ssh_env}
chmod 600 $ssh_env
source $ssh_env >/dev/null
# load identies
zstyle -a :omz:plugins:ssh-agent identities identities
ssh-add $HOME/.ssh/${^identities}
}
function keychain() {
case $1 in
"start") ;;
"kill")
ssh-agent -k
;;
esac
}
zstyle -a :omz:plugins:keychain autostart state
if [[ $state == "on" ]]; then
if [[ -f $ssh_env ]]; then
source $ssh_env >/dev/null
ps -p $SSH_AGENT_PID >/dev/null || start_agent
else
start_agent;
fi
fi
unfunction start_agent
unset ssh_env

View file

@ -1,33 +0,0 @@
local ssh_env=$HOME/.ssh/environment-$HOST
# local state
function start_agent()
{
local -a identities
# start ssh-agent and setup environment
ssh-agent | sed 's/^echo/#echo/' >${ssh_env}
chmod 600 $ssh_env
source $ssh_env >/dev/null
# load identies
zstyle -a :omz:plugins:ssh-agent identities identities
ssh-add $HOME/.ssh/${^identities}
}
# test if agent-forwarding is enabled
# zstyle -b :omz:plugins:ssh-agent agent-forwarding state
# if [[ $state == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# [[ -L $SSH_AUTH_SOCK ]] || ln -sf $SSH_AUTH_SOCK /tmp/ssh-agent-$USER-screen
if [[ -f $ssh_env ]]; then
source $ssh_env >/dev/null
ps -p $SSH_AGENT_PID >/dev/null || start_agent
else
start_agent;
fi
# tidy up after ourselves
unfunction start_agent
# unset state
unset ssh_env