dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit 971ec352abbdc2a690318f18a3fec2153a754023
parent d4f12ec2e6ce696c21a896996ec8b8a6f7492a0f
Author: Chris Bracken <chris@bracken.jp>
Date:   Tue, 10 Oct 2023 00:57:05 -0700

ssh-agent: set environment variable with systemd

Creates a socket at $SSH_AUTH_SOCK using systemd. References this from
.zprofile.

This feels like a bit of a hack; it would be nice if there were were a
cleaner way to write this.

Diffstat:
M.config/zsh/.zprofile | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile @@ -3,9 +3,12 @@ # Set the terminal size if we're on a serial line. if [[ -x /usr/bin/resizewin ]]; then /usr/bin/resizewin -z; fi -if [[ "$(uname)" == "FreeBSD" ]]; then +if [[ "$(uname)" == "Linux" || "$(uname)" == "FreeBSD" ]]; then + # ssh-agent is started by systemd; add the socket path to the environment. + export "$(systemctl --user show-environment | grep '^SSH_AUTH_SOCK=')" +elif [[ "$(uname)" == "FreeBSD" ]]; then # Start ssh-agent daemon. - export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.sock" + export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" ssh-add -l 2>/dev/null >/dev/null if [ $? -ge 2 ]; then # If not already running, start ssh-agent. Stop on shell exit.