1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2026-04-18 13:24:04 +00:00

ssh: Use idiomatic zsh array operations instead of sed/grep forks

This commit is contained in:
Indrajit Raychaudhuri
2026-03-22 02:01:11 -05:00
parent e5444ce534
commit 2e3fbc8fac

View File

@@ -27,7 +27,7 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
# Start ssh-agent if not started.
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then
mkdir -p "$_ssh_agent_env:h"
eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
eval "$(print -l "${(@)${(f)"$(ssh-agent)"}:#echo *}" | tee "$_ssh_agent_env")"
fi
fi
@@ -39,7 +39,7 @@ if [[ -S "$SSH_AUTH_SOCK" && "$SSH_AUTH_SOCK" != "$_ssh_agent_sock" ]]; then
fi
# Load identities.
if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then
if [[ ${(@M)${(f)"$(ssh-add -l 2>&1)"}:#The agent has no identities*} ]]; then
zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities'
# ssh-add has strange requirements for running SSH_ASKPASS, so we duplicate
# them here. Essentially, if the other requirements are met, we redirect stdin