From 9b1c49e94726a5ae85db89a211c8ebf3290fe87c Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Mon, 11 Aug 2014 23:07:45 +0200 Subject: zprofile: Move ssh/gpg-agent things to profile-leeloo --- zsh/.zprofile | 23 ++--------------------- zsh/profile-leeloo | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 zsh/profile-leeloo (limited to 'zsh') diff --git a/zsh/.zprofile b/zsh/.zprofile index 0871e85..a0ca536 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -41,27 +41,8 @@ export FQDN=$(hostname -f) # LS_COLORS is now required for `ls` to use colour source <(dircolors -b "$XDG_CONFIG_HOME"/dircolors) -function { - local envfile="$XDG_RUNTIME_DIR"/gpg-agent.env - if [[ -e "$envfile" ]] && kill -0 $(cut -d':' -f2 <"$envfile") &>/dev/null; then - source "$envfile" - else - source <(gpg-agent --daemon --write-env-file "$envfile") - export GPG_AGENT_INFO - fi -} - -function { - local envfile="$XDG_RUNTIME_DIR"/ssh-agent.env - local pid=$(awk -F'[=;]' 'FNR == 2 {print $2}' "$envfile" 2>/dev/null) - - if [[ -n "$pid" ]] && kill -0 "$pid" &>/dev/null; then - source "$envfile" >/dev/null - else - ssh-agent > "$envfile" - source "$envfile" >/dev/null - fi -} +[[ -f "$ZDOTDIR"/profile-"$(hostname -s)" ]] && \ + source "$ZDOTDIR"/profile-"$(hostname -s)" if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then exec startx "$XDG_CONFIG_HOME"/X11/xinitrc diff --git a/zsh/profile-leeloo b/zsh/profile-leeloo new file mode 100644 index 0000000..c74e1f7 --- /dev/null +++ b/zsh/profile-leeloo @@ -0,0 +1,23 @@ +function { + local envfile="$XDG_RUNTIME_DIR"/gpg-agent.env + if [[ -e "$envfile" ]] && kill -0 $(cut -d':' -f2 <"$envfile") &>/dev/null; then + source "$envfile" + else + source <(gpg-agent --daemon --write-env-file "$envfile") + export GPG_AGENT_INFO + fi +} + +function { + local envfile="$XDG_RUNTIME_DIR"/ssh-agent.env + local pid=$(awk -F'[=;]' 'FNR == 2 {print $2}' "$envfile" 2>/dev/null) + + if [[ -n "$pid" ]] && kill -0 "$pid" &>/dev/null; then + source "$envfile" >/dev/null + else + ssh-agent > "$envfile" + source "$envfile" >/dev/null + fi +} + +# vim: ft=zsh: -- cgit v1.2.3-70-g09d2