else
echo "Sorry, zsh version too old"
fi
+
+function agent() {
+ local agent agentfiles af
+ local _agent_ssh_env=${HOME}/.ssh/agentenv.${HOST}
+ typeset -a agentfiles
+
+ touch ${_agent_ssh_env}
+ chmod 0600 ${_agent_ssh_env}
+
+ zstyle -s ':ganneff:config' agent agent || agent=gpg-agent
+ case ${agent} in
+ gpg-agent)
+ if is-callable gpg-agent; then
+ eval $(gpg-agent --enable-ssh-support \
+ --daemon \
+ --write-env-file ${_agent_ssh_env})
+ else
+ print "gpg-agent binary not found"
+ return 1
+ fi
+ ;;
+ ssh-agent)
+ if is-callable ssh-agent; then
+ ssh-agent | sed s'/^echo/#echo/g' >| ${_agent_ssh_env}
+ source ${_agent_ssh_env}
+ else
+ print "ssh-agent binary not found"
+ return 1
+ fi
+ ;;
+ *)
+ print "Unknown agent ${agent}, not doing anything!"
+ ;;
+ esac
+
+ zstyle -a ':ganneff:config' agentfiles agentfiles || agentfiles = ()
+ for af in ${agentfiles}; do
+ ssh-add ${af}
+ done
+
+ if is434 && zstyle -T ':ganneff:config' killagent true; then
+ add-zsh-hook zshexit kill_agent
+ fi
+}
+
+function kill_agent() {
+ local _agent_ssh_env=${HOME}/.ssh/agentenv.${HOST}
+ kill -TERM ${SSH_AGENT_PID}
+ rm -f ${_agent_ssh_env}
+}
dirpersistrestore
fi
+if zstyle -t ':ganneff:config' doagent; then
+ agent
+fi
export GPG_TTY=$(tty)
setvar PAGER "$(which less)"
## any (and if they are installed)
# zstyle ':ganneff:config' termstatus true
+## Easy way to setup ssh agent. Usually ssh-agent (or gpg-agent) should
+## be setup outside zsh, like at X login time, and just serve your
+## terminals with their zshs inside.
+## But there are situations one does not have that environment around
+## (say, login to a remote machine) and still want an agent.
+##
+## Should we setup the agent automagically on every zsh startup?
+## If false then we only setup the agent/kill_agent functions to be
+## there.
+## If true we also execute the agent function and may load the keys.
+# zstyle ':ganneff:config' doagent false
+
+## Which ssh keys to add to the agent? Empty if not given, then you can
+## manually do the ssh-add runs. Otherwise a list with path entries.
+# zstyle ':ganneff:config' agentfiles
+
+## Should we kill the agent at zsh exit?
+# zstyle ':ganneff:config' killagent true
+
+## Use ssh-agent or gpg-agent?
+# zstyle ':ganneff:config' agent gpg-agent
+
########################################################################
### Prompt setup ###
## use vcs_info in prompt