From edf8034308d9bed57fda7c57152236fc7435b8a9 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Wed, 25 May 2022 14:37:29 -0700 Subject: [PATCH] [zsh] Convert zprofile to do_init_functions --- zprofile | 27 ++++++--------------------- zsh/func/init_profile_darwin | 8 ++++++++ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/zprofile b/zprofile index f7b3952..190aeaf 100644 --- a/zprofile +++ b/zprofile @@ -1,26 +1,11 @@ #!/usr/bin/env zsh # Eryn Wells -# Start SSH agent for password-less logins -if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then - if ! pgrep -u $USER ssh-agent 1>/dev/null; then - eval $(ssh-agent -s > ~/.ssh_agent_vars) - trap "kill $SSH_AGENT_PID" 0 - else - eval $(cat ~/.ssh_agent_vars) - fi -fi +zsh_init_profile_functions=( \ + connect_ssh_agent \ + init_profile_$SYS \ + list_tmux_sessions \ +) -autoload -Uz list_tmux_sessions -autoload -Uz binary_exists +do_init_functions zsh_init_profile_functions -if binary_exists sw_vers && binary_exists lolcat; then - case $SYS in - darwin) - print "It's `date +'%H:%M on %A, %B %d'`.\nThis machine is a $HWMODEL.\nYou're running macOS $OSVERSION.\n" | lolcat - ;; - *) ;; - esac -fi - -list_tmux_sessions diff --git a/zsh/func/init_profile_darwin b/zsh/func/init_profile_darwin index 8225b42..6798c45 100644 --- a/zsh/func/init_profile_darwin +++ b/zsh/func/init_profile_darwin @@ -5,3 +5,11 @@ if ssh-add --apple-load-keychain; then echo fi +if binary_exists sw_vers; then + cat_program=cat + if binary_exists lolcat; then + cat_program=lolcat + fi + print "It's `date +'%H:%M on %A, %B %d'`.\nThis machine is a $HWMODEL.\nYou're running macOS $OSVERSION.\n" | $cat_program +fi +