From fe16145508e851a75451290ca2a14359deafd0f7 Mon Sep 17 00:00:00 2001 From: odrling Date: Tue, 21 Apr 2020 03:05:16 +0200 Subject: [PATCH] [profile] move ssh_agent initialization in .zshrc --- .profile | 3 --- .zshrc | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.profile b/.profile index 14fcf5d..48e8dae 100644 --- a/.profile +++ b/.profile @@ -9,9 +9,6 @@ export FZF_DEFAULT_COMMAND="find . -type f | cut -d'/' -f2-" # fix java swing applications export _JAVA_AWT_WM_NONREPARENTING=1 -# start ssh-agent -eval $(ssh-agent) - [ -f ~/.profile.local ] && . ~/.profile.local if [ "$(tty)" = '/dev/tty1' ]; then diff --git a/.zshrc b/.zshrc index f8fc409..b3c7c7c 100644 --- a/.zshrc +++ b/.zshrc @@ -1,6 +1,21 @@ stty -ixon # Disable ctrl-s and ctrl-q. +# ssh-agent +start_ssh_agent() { + ssh-agent | grep -v \^echo > "$SSH_ENV" + chmod 1600 "$SSH_ENV" +} + +SSH_ENV="/tmp/.ssh_env.$USER" +if [ -f "$SSH_ENV" ]; then + . "$SSH_ENV" + ps q $SSH_AGENT_PID > /dev/null || start_ssh_agent +else + start_ssh_agent +fi +. "$SSH_ENV" + # load modules bgnotify_threshold=0 for i in ~/.zsh/*/*.plugin.zsh; do @@ -67,3 +82,4 @@ alias ffprobe="ffprobe -hide_banner" [ -f ~/.local_env ] && . ~/.local_env [ -f ~/.zshrc.local ] && . ~/.zshrc.local [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +