mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
Renamed ssh-agent plugin keychain.
This commit is contained in:
parent
bceecbccff
commit
134a262d65
2 changed files with 37 additions and 33 deletions
37
plugins/keychain/keychain.plugin.zsh
Normal file
37
plugins/keychain/keychain.plugin.zsh
Normal 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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue