Update 30.01.2022

This commit is contained in:
2022-01-30 00:39:21 +05:00
parent 3d6a64111c
commit 04423b8c5c
323 changed files with 44877 additions and 7114 deletions

View File

@@ -6,9 +6,11 @@ function _start_agent() {
if [[ -f "$ssh_env_cache" ]]; then
. "$ssh_env_cache" > /dev/null
{
[[ "$USERNAME" = root ]] && command ps ax || command ps x
} | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
# Test if $SSH_AUTH_SOCK is visible
zmodload zsh/net/socket
if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then
return 0
fi
fi
# Set a maximum lifetime for identities added to ssh-agent
@@ -16,7 +18,7 @@ function _start_agent() {
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
# start ssh-agent and setup environment
echo Starting ssh-agent...
zstyle -t :omz:plugins:ssh-agent quiet || echo >&2 "Starting ssh-agent ..."
ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache"
chmod 600 "$ssh_env_cache"
. "$ssh_env_cache" > /dev/null
@@ -76,7 +78,7 @@ function _add_identities() {
if [[ -n "$helper" ]]; then
if [[ -z "${commands[$helper]}" ]]; then
echo "ssh-agent: the helper '$helper' has not been found."
echo >&2 "ssh-agent: the helper '$helper' has not been found."
else
SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
return $?
@@ -86,17 +88,18 @@ function _add_identities() {
ssh-add "${args[@]}" ${^not_loaded}
}
# test if agent-forwarding is enabled
zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding
# Add a nifty symlink for screen/tmux if agent forwarding
if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
else
_start_agent
fi
_add_identities
# Don't add identities if lazy-loading is enabled
if ! zstyle -t :omz:plugins:ssh-agent lazy; then
_add_identities
fi
unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities