diff options
author | Matt Strapp <matt@mattstrapp.net> | 2025-03-18 16:23:10 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2025-03-18 16:23:10 -0500 |
commit | 38cfe6377b00b51a0e5519f1c6baaafcb321aa42 (patch) | |
tree | f33209a46e8e926e4e43d7f248619e4ad254462b | |
parent | update vim config, delete p10k (diff) | |
download | dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar.gz dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar.bz2 dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar.lz dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar.xz dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.tar.zst dotfiles-38cfe6377b00b51a0e5519f1c6baaafcb321aa42.zip |
make sure ssh agent does not recreate itself over ssh
-rw-r--r-- | dot_config/zsh/dot_zshrc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index 036bfac..8af2021 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -33,12 +33,15 @@ if [ -x "$(command -v gem)" ]; then export PATH="$PATH:$GEM_HOME/bin" fi -# Make sure ssh-agent runs -if ! pgrep -u "$USER" ssh-agent > /dev/null; then - ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" -fi -if [ ! -f "$SSH_AUTH_SOCK" ]; then - source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null +# Make sure ssh-agent runs only when not already connected over ssh +if [[ -z "${SSH_CONNECTION}" ]]; then + if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" + fi + + if [ ! -f "$SSH_AUTH_SOCK" ]; then + source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null + fi fi # Enable colors and change prompt: |