Artificial intelligent assistant

Execute a function before specific programs This began with the want of adding SSH keys to `ssh-agend` on demand, but because this isn't possible with OpenSSH, I came up with this zsh script instead. But for a reason I can't figure out, instead of only running "before" `ssh` or `git`, it is run before _anything_ , even empty commands. git ssh () { # Does the agent handle any keys? ssh-add -l &>/dev/null # True if last executed command (ssh-add -l) exits non-zero. if [ $? -ne 0 ]; then ssh-add fi # Execute git or ssh with all parameters, and not this function command $0 "$@" } Why does this function execute after every command instead of only when `git` or `ssh` is entered?

I tried the function with `zsh -f` (which I should have done before posting..), and found that it worked as expected. Something else is causing this issue, so I'm closing this question when able.

**EDIT** :

For those interested in what the issue was, and how it was solved, look below.

I used the zsh framework ZIM which uses `vcs_info` to check if the current directory is used by git or not. This requires a call to git. `vcs_info` itself does not call git directly, it would seem, not by default.

However, thanks to ft on #zsh on Freenode, adding

`zstyle ':vcs_info:git:*:-all-' command =git`

to `~/.zshrc` after the framework has been sourced, has fixed this issue.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a969d40a45a07d22c8ad5b9572fd591a