diff --git a/bash/bash_login b/bash/bash_login index 1c993ccb0..af3d0412c 100644 --- a/bash/bash_login +++ b/bash/bash_login @@ -6,11 +6,17 @@ systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT source ${HOME}/.dotfiles/bash/bash_aliases # Configure static SSH Agent -export SSH_AUTH_SOCK=~/.spool/ssh-agent.sock +export SSH_AUTH_SOCK=$HOME/.spool/ssh-agent.sock if [ -e $SSH_AUTH_SOCK ]; then rm $SSH_AUTH_SOCK fi -ssh-agent -a "$SSH_AUTH_SOCK" >/dev/null +if [ -e $HOME/.spool/ssh-agent.env ]; then + rm $HOME/.spool/ssh-agent.env +fi +if [[ "`pgrep ssh-agent`" ]]; then + pkill ssh-agent +fi +. $HOME/scripts/ssh-agent.sh # Static/predictable Sway socket export SWAYSOCK=`sway --get-socketpath` diff --git a/bash/bash_logout b/bash/bash_logout index b01fb7784..ee06f98d6 100644 --- a/bash/bash_logout +++ b/bash/bash_logout @@ -2,8 +2,9 @@ if [ ! $SSH_TTY ]; then # Remove socket files - rm SSH_AUTH_SOCK - rm SWAYSOCK + rm $SSH_AUTH_SOCK + rm $HOME/.spool/ssh-agent.env + rm $SWAYSOCK fi # when leaving the console clear the screen to increase privacy diff --git a/bash/bashrc b/bash/bashrc index 83c7f513c..63ebd9a92 100644 --- a/bash/bashrc +++ b/bash/bashrc @@ -93,6 +93,16 @@ export TERM="xterm" echo -e -n "\033]2;Welcome to Bash\007" SSH_AUTH_SOCK="$HOME/.spool/ssh-agent.sock" +if [ -z $SSH_AGENT_PID ]; then + if [ -f "$HOME/.spool/ssh-agent.env" ]; then + source $HOME/.spool/ssh-agent.env >/dev/null + else + if [ ! -f $SSH_AUTH_SOCK ]; then + touch $SSH_AUTH_SOCK + fi + $HOME/scripts/ssh-agent.sh + fi +fi # Distrobox only if [ -f "/run/.containerenv" ]; then