From 4edb07531ccc6c71180d1840e1ace176e446f830 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Thu, 25 Aug 2022 11:31:58 +0100 Subject: [PATCH] Fix SSH agent detection --- roles/home-cli/files/shrc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/home-cli/files/shrc b/roles/home-cli/files/shrc index 62ca18e..31498d7 100644 --- a/roles/home-cli/files/shrc +++ b/roles/home-cli/files/shrc @@ -3,6 +3,11 @@ if [ -n "$_acp_ignore_shrc" ] then return 1 fi +if [ -n "$_acp_shrc_loaded" ] +then + return 1 +fi +export _acp_shrc_loaded=1 case "$-" in *i*) @@ -152,11 +157,14 @@ fi alias prun='podman run --rm --interactive --tty --security-opt label=disable --volume "$HOME":"$HOME" --volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" --env XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" --env XDG_SESSION_TYPE=wayland --ipc host' alias pruncerts='prun --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro --volume /etc/ssl/certs:/etc/ssl/certs:ro' -if command -v ssh-agent > /dev/null && [ -z "$SSH_AUTH_SOCK" ] && [ -z "$SSH_AGENT_PID" ] +if command -v ssh-agent > /dev/null then - export SSH_AUTH_SOCK="$XDG_STATE_HOME/ssh-agent.socket" - export SSH_AGENT_PID="$XDG_STATE_HOME/ssh-agent.pid" - ssh-agent -a "$SSH_AUTH_SOCK" + export SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-$XDG_STATE_HOME/ssh-agent.socket}" + export SSH_AGENT_PID="${SSH_AGENT_PID:-$XDG_STATE_HOME/ssh-agent.pid}" + if [ ! -S "$SSH_AUTH_SOCK" ] + then + ssh-agent -a "$SSH_AUTH_SOCK" + fi fi mkcd () {