79085227

Date: 2024-10-14 08:03:34
Score: 1
Natty:
Report link

Minor updates to @michael-ekstrand answer

  1. Prevent unnecessary function definitions
  2. Wrap expensive tmux calls with simnple builtin tests
  3. Prevent error if $SSH_AUTH_SOCK contains whitespace
if [[ -n $TMUX ]]; then
  _update_ssh_agent() {
    if ! [[ -S $SSH_AUTH_SOCK ]]; then
      eval "$(tmux show-environment -s SSH_AUTH_SOCK 2>/dev/null)"
    fi
  }
  add-zsh-hook precmd _update_ssh_agent
fi
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @michael-ekstrand
  • Low reputation (0.5):
Posted by: jaqque