From 5d924b2e04257d620417c7d5a1cbe5e603379424 Mon Sep 17 00:00:00 2001 From: Robin Roth Date: Wed, 25 Nov 2015 17:21:58 +0100 Subject: [PATCH] add quiet option to ssh-agent plugin allows to switch off output and addition of ssh identities --- plugins/ssh-agent/ssh-agent.plugin.zsh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 610ad34dc..15b7c7dfa 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -18,6 +18,12 @@ # # zstyle :omz:plugins:ssh-agent lifetime 4h # +# To make the plugin not ouput anything use the quiet style. +# This prevents ouput messages and ssh-add, which might ask +# for a passphrase. +# +# zstyle :omz:plugins:ssh-agent quiet yes +# # CREDITS # # Based on code from Joseph M. Reagle @@ -32,7 +38,6 @@ local _plugin__forwarding function _plugin__start_agent() { - local -a identities local lifetime zstyle -s :omz:plugins:ssh-agent lifetime lifetime @@ -41,11 +46,16 @@ function _plugin__start_agent() chmod 600 ${_plugin__ssh_env} . ${_plugin__ssh_env} > /dev/null - # load identies - zstyle -a :omz:plugins:ssh-agent identities identities - echo starting ssh-agent... + local quiet + zstyle -b :omz:plugins:ssh-agent quiet quiet + if [[ ! ${quiet} == "yes" ]]; then + local -a identities + # load identities + zstyle -a :omz:plugins:ssh-agent identities identities + echo starting ssh-agent... - /usr/bin/ssh-add $HOME/.ssh/${^identities} + /usr/bin/ssh-add $HOME/.ssh/${^identities} + fi } # Get the filename to store/lookup the environment from