This commit is contained in:
33
.config/zsh/rc/gpg-agent.zsh
Normal file
33
.config/zsh/rc/gpg-agent.zsh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-gpg-agent() {
|
||||
## don't bother with gpg agent socket if it already set
|
||||
[ -z "${GPG_AGENT_INFO}" ] || return 0
|
||||
|
||||
(( ${+commands[gpg-agent]} )) || return 127
|
||||
|
||||
local u
|
||||
for u in gpg-agent.{service,socket} ; do
|
||||
z-systemctl-exists --user $u || continue
|
||||
|
||||
z-systemctl --user --now enable $u
|
||||
done
|
||||
|
||||
(( ${+commands[gpgconf]} )) || return 127
|
||||
|
||||
local agent_sock
|
||||
agent_sock=$(command gpgconf --list-dirs agent-socket) || return $?
|
||||
[ -n "${agent_sock}" ] || return 3
|
||||
export GPG_AGENT_INFO="${agent_sock}:0:1"
|
||||
|
||||
## don't bother with ssh agent socket if it already set
|
||||
[ -z "${SSH_AUTH_SOCK}" ] || return 0
|
||||
|
||||
local want_ssh_agent ssh_auth_sock
|
||||
want_ssh_agent=$(z-gpgconf-getopt gpg-agent enable-ssh-support)
|
||||
if [ "${want_ssh_agent}" = 1 ] ; then
|
||||
ssh_auth_sock=$(command gpgconf --list-dirs agent-ssh-socket) || return $?
|
||||
[ -n "${ssh_auth_sock}" ] || return 5
|
||||
export SSH_AUTH_SOCK="${ssh_auth_sock}"
|
||||
fi
|
||||
}
|
29
.config/zsh/rc/ssh-agent.zsh
Normal file
29
.config/zsh/rc/ssh-agent.zsh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/zsh
|
||||
|
||||
z-ssh-agent() {
|
||||
while [ -n "${SSH_AGENT_PID}" ] ; do
|
||||
z-proc-exists "${SSH_AGENT_PID}" || break
|
||||
|
||||
## don't bother with ssh agent socket if it already set
|
||||
[ -z "${SSH_AUTH_SOCK}" ] || return 0
|
||||
|
||||
break
|
||||
done
|
||||
|
||||
(( ${+commands[ssh-agent]} )) || return 127
|
||||
|
||||
if [ -z "${SSH_AUTH_SOCK}" ] ; then
|
||||
local sock_dir
|
||||
if [ "${XDG_RUNTIME_DIR}" = "${TMPDIR}" ] ; then
|
||||
sock_dir="${ZSHU[d_zdot]}/.cache/ssh"
|
||||
else
|
||||
sock_dir="${XDG_RUNTIME_DIR}/ssh"
|
||||
fi
|
||||
mkdir -p "${sock_dir}"
|
||||
SSH_AUTH_SOCK="${sock_dir}/ssh-agent.sock"
|
||||
fi
|
||||
|
||||
{
|
||||
eval "$(ssh-agent -s -k -a "${SSH_AUTH_SOCK}")"
|
||||
} >/dev/null
|
||||
}
|
@@ -5,8 +5,9 @@ z-orig-term() {
|
||||
local i x
|
||||
|
||||
for i ( ${ZSHU_PARENTS_PID} ) ; do
|
||||
[ -r "/proc/$i/environ" ] || continue
|
||||
x=$(sed -zEn '/^TERM=(.+)$/{s//\1/;p;}' "/proc/$i/environ" 2>/dev/null | tr -d '\0')
|
||||
i="${ZSHU[procfs]}/$i/environ"
|
||||
[ -r "$i" ] || continue
|
||||
x=$(sed -zEn '/^TERM=(.+)$/{s//\1/;p;}' "$i" 2>/dev/null | tr -d '\0')
|
||||
[ -n "$x" ] || continue
|
||||
a+=( "$x" )
|
||||
done
|
||||
|
Reference in New Issue
Block a user