{bash,zsh}rc: use user-specific runtime directory rather than /tmp for ssh-agent

This commit is contained in:
Aminda Suomalainen 2026-01-22 09:02:28 +02:00
parent f43e244d42
commit 064885e8b4
Signed by: Mikaela
GPG Key ID: 99392F62BAE30723
2 changed files with 26 additions and 14 deletions

View File

@ -250,9 +250,15 @@ if [ -f ~/.gnupg/sshcontrol ]; then
gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1
# otherwise use the normal ssh-agent # otherwise use the normal ssh-agent
else else
if hash xdg-user-dir 2> /dev/null; then
# if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a $(xdg-user-dir RUNTIME)/sshagent > /dev/null 2>&1)
export SSH_AUTH_SOCK=$(xdg-user-dir RUNTIME)/sshagent
else
# if the output is going to /dev/null, it's non/existence doesn't matter # if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1) (ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent export SSH_AUTH_SOCK=/tmp/$USER.sshagent
fi
fi fi
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/ # OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
@ -1027,9 +1033,9 @@ if [ -f ~/.bash_custom ]; then
source ~/.bash_custom source ~/.bash_custom
fi fi
# If $TMUX, then TERM is tmux-256color # Note if my xdg runtime dir setting is broken.
#if [ -v TMUX ]; then if ! hash xdg-user-dir 2> /dev/null; then
# TERM=tmux-256color echo "WARNING! xdg-user-dir not found."
#fi fi
# vim: filetype=bash # vim: filetype=bash

View File

@ -206,9 +206,15 @@ if [ -f ~/.gnupg/sshcontrol ]; then
gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1
# otherwise use the normal ssh-agent # otherwise use the normal ssh-agent
else else
if hash xdg-user-dir 2> /dev/null; then
# if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a $(xdg-user-dir RUNTIME)/sshagent > /dev/null 2>&1)
export SSH_AUTH_SOCK=$(xdg-user-dir RUNTIME)/sshagent
else
# if the output is going to /dev/null, it's non/existence doesn't matter # if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1) (ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent export SSH_AUTH_SOCK=/tmp/$USER.sshagent
fi
fi fi
# If we are on Linux, enable apt progress bar and colours # If we are on Linux, enable apt progress bar and colours
@ -1019,9 +1025,9 @@ if [ -f ~/.warnings ]; then
source ~/.warnings source ~/.warnings
fi fi
# If $TMUX, then TERM is tmux-256color # Note if my xdg runtime dir setting is broken.
#if [ -v TMUX ]; then if ! hash xdg-user-dir 2> /dev/null; then
# TERM=tmux-256color echo "WARNING! xdg-user-dir not found."
#fi fi
# vim: filetype=zsh # vim: filetype=zsh