From db942546e2b3e1c24026a0f2617cbbd6dc7f6fad Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 27 Oct 2018 23:30:05 +0200 Subject: zsh: ssh-agent --- zsh/.zshrc | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index 9f9aaf2..5f0bbe2 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -29,6 +29,30 @@ zstyle '*' hosts # do not use /etc/hosts ZDIR=~/.zsh/ _HOST_TYPE=$(uname) +# ############################################################################# +# ssh-agent +# ############################################################################# + +SSH_ENV="$HOME/.ssh/environment" + +function start_agent { + echo "Initialising new SSH agent..." + /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" + echo succeeded + chmod 600 "${SSH_ENV}" + . "${SSH_ENV}" > /dev/null + /usr/bin/ssh-add; +} + +if [ -f "${SSH_ENV}" ]; then + . "${SSH_ENV}" > /dev/null + ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { + start_agent; + } +else + start_agent; +fi + # ############################################################################# # functions # ############################################################################# @@ -213,11 +237,11 @@ if [[ $(on_gcloud) == "yes" ]]; then fi # aws -if [[ $(on_aws) == "yes" ]]; then - HOSTCOLOR_BG=yellow - HOSTCOLOR_FG=black - alias tmux="tmux -f ~/.tmux.aws.conf" -fi +#if [[ $(on_aws) == "yes" ]]; then +# HOSTCOLOR_BG=yellow +# HOSTCOLOR_FG=black +# alias tmux="tmux -f ~/.tmux.aws.conf" +#fi function chpwd { -- cgit v1.2.3