This commit is contained in:
David Tomaschik
2026-02-20 17:15:39 -08:00
parent 1c0c5dd32b
commit 00696b23fa
5 changed files with 40 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ uvx = true
uv_venv_auto = true uv_venv_auto = true
[tools] [tools]
age = "latest"
uv = "latest" uv = "latest"
[hooks] [hooks]

View File

@@ -27,3 +27,6 @@ id_ed25519
# These files should basically never be committed # These files should basically never be committed
.env .env
# Mise local
mise.local.toml

View File

@@ -87,6 +87,34 @@ export LVM_SUPPRESS_FD_WARNINGS=1
# Default disable SSH forwarding in EARTHLY # Default disable SSH forwarding in EARTHLY
export EARTHLY_SSH_AUTH_SOCK="" export EARTHLY_SSH_AUTH_SOCK=""
# Handle SSH_AUTH_SOCK for tmux consistency
_SSH_AUTH_LINK="${HOME}/.ssh/ssh_auth_sock"
if [ -z "${SSH_AUTH_SOCK:-}" ] || [ ! -S "${SSH_AUTH_SOCK}" ] ; then
# Try to find a working GPG agent SSH socket if no agent is set or current is broken
if command -v gpgconf >/dev/null 2>&1; then
_GPG_SSH_SOCK=$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)
fi
# Fallback to common paths if gpgconf fails or isn't present
if [ -z "${_GPG_SSH_SOCK}" ] || [ ! -S "${_GPG_SSH_SOCK}" ]; then
_GPG_SSH_SOCK="${GNUPGHOME:-$HOME/.gnupg}/S.gpg-agent.ssh"
[ -S "$_GPG_SSH_SOCK" ] || _GPG_SSH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"
fi
if [ -S "${_GPG_SSH_SOCK}" ] ; then
export SSH_AUTH_SOCK="$_GPG_SSH_SOCK"
fi
unset _GPG_SSH_SOCK
fi
# If we have a valid socket but it's not our stable link, sync the link and use it.
# This ensures tmux (using the static path) always finds the most recent agent.
if [ -S "${SSH_AUTH_SOCK:-}" ] && [ "${SSH_AUTH_SOCK}" != "${_SSH_AUTH_LINK}" ] ; then
[ -d "$(dirname "${_SSH_AUTH_LINK}")" ] || mkdir -p "$(dirname "${_SSH_AUTH_LINK}")"
ln -sf "${SSH_AUTH_SOCK}" "${_SSH_AUTH_LINK}"
export SSH_AUTH_SOCK="${_SSH_AUTH_LINK}"
fi
unset _SSH_AUTH_LINK
# Setup XDG-like dirs on MacOS # Setup XDG-like dirs on MacOS
# Based on https://leebyron.com/til/mac-xdg/ # Based on https://leebyron.com/til/mac-xdg/
if [ "$(uname)" = "Darwin" ] ; then if [ "$(uname)" = "Darwin" ] ; then

View File

@@ -8,11 +8,13 @@ REMOTE_LINK="${HOME}/.ssh/ssh_auth_sock"
if [ -S "${SSH_AUTH_SOCK}" ] ; then if [ -S "${SSH_AUTH_SOCK}" ] ; then
SSH_REMOTE_AUTH_SOCK="${SSH_AUTH_SOCK}" SSH_REMOTE_AUTH_SOCK="${SSH_AUTH_SOCK}"
export SSH_REMOTE_AUTH_SOCK export SSH_REMOTE_AUTH_SOCK
if [ "${1:-}" = "force" ] || [ ! -S "${REMOTE_LINK}" ] ; then # Always update the symlink to the latest session's socket.
ln -sf "${SSH_AUTH_SOCK}" "${REMOTE_LINK}" # This ensures that tmux (which uses the static path) always points to a
SSH_AUTH_SOCK="${REMOTE_LINK}" # current agent.
export SSH_AUTH_SOCK mkdir -p "$(dirname "${REMOTE_LINK}")"
fi ln -sf "${SSH_AUTH_SOCK}" "${REMOTE_LINK}"
SSH_AUTH_SOCK="${REMOTE_LINK}"
export SSH_AUTH_SOCK
fi fi
# if stdin is a tty, don't do the cookie step # if stdin is a tty, don't do the cookie step

View File

@@ -29,16 +29,7 @@ if grep -q '^enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then
# Load required functions. # Load required functions.
autoload -Uz add-zsh-hook autoload -Uz add-zsh-hook
if test -z "$SSH_AUTH_SOCK" ; then # Updates the GPG-Agent TTY before every command since SSH does not set it.
SSH_AUTH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"
if test -S "$SSH_AUTH_SOCK" ; then
export SSH_AUTH_SOCK
else
unset SSH_AUTH_SOCK
fi
fi
# Updates the GPG-Agent TTY before every command since SSH does not set it.
function _gpg-agent-update-tty { function _gpg-agent-update-tty {
gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null
} }