abra zsh config 2.0

This commit is contained in:
Andrey Anurin
2018-08-12 15:26:21 +03:00
parent 201abd09c4
commit 6b114440e2
1195 changed files with 68948 additions and 10539 deletions

View File

@@ -6,7 +6,7 @@
#
# Return if requirements are not found.
if [[ "$OSTYPE" == darwin* ]] || (( ! $+commands[ssh-agent] )); then
if (( ! $+commands[ssh-agent] )); then
return 1
fi
@@ -14,10 +14,10 @@ fi
_ssh_dir="$HOME/.ssh"
# Set the path to the environment file if not set by another module.
_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env}"
_ssh_agent_env="${_ssh_agent_env:-${TMPDIR:-/tmp}/ssh-agent.env.$UID}"
# Set the path to the persistent authentication socket.
_ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock"
_ssh_agent_sock="${TMPDIR:-/tmp}/ssh-agent.sock.$UID"
# Start ssh-agent if not started.
if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
@@ -25,10 +25,8 @@ if [[ ! -S "$SSH_AUTH_SOCK" ]]; then
source "$_ssh_agent_env" 2> /dev/null
# Start ssh-agent if not started.
if [[ -z $SSH_CLIENT ]]; then
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then
eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
fi
if ! ps -U "$LOGNAME" -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then
eval "$(ssh-agent | sed '/^echo /d' | tee "$_ssh_agent_env")"
fi
fi
@@ -41,10 +39,20 @@ fi
# Load identities.
if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then
zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities'
if (( ${#_ssh_identities} > 0 )); then
ssh-add "$_ssh_dir/${^_ssh_identities[@]}" 2> /dev/null
# ssh-add has strange requirements for running SSH_ASKPASS, so we duplicate
# them here. Essentially, if the other requirements are met, we redirect stdin
# from /dev/null in order to meet the final requirement.
#
# From ssh-add(1):
# If ssh-add needs a passphrase, it will read the passphrase from the current
# terminal if it was run from a terminal. If ssh-add does not have a terminal
# associated with it but DISPLAY and SSH_ASKPASS are set, it will execute the
# program specified by SSH_ASKPASS and open an X11 window to read the
# passphrase.
if [[ -n "$DISPLAY" && -x "$SSH_ASKPASS" ]]; then
ssh-add ${_ssh_identities:+$_ssh_dir/${^_ssh_identities[@]}} < /dev/null 2> /dev/null
else
ssh-add 2> /dev/null
ssh-add ${_ssh_identities:+$_ssh_dir/${^_ssh_identities[@]}} 2> /dev/null
fi
fi