From 459ebef612907c823206088430e0d6c478cb03da Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Fri, 3 Jun 2011 09:35:33 -0700 Subject: [PATCH] add comment, fix a performance bug when $EDITOR is not set, reformat. --- plugins/git/git-prompt.plugin.zsh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/git/git-prompt.plugin.zsh b/plugins/git/git-prompt.plugin.zsh index d4745992..8fd9364c 100644 --- a/plugins/git/git-prompt.plugin.zsh +++ b/plugins/git/git-prompt.plugin.zsh @@ -584,6 +584,10 @@ precmd_functions+='_git_prompt__precmd_update_git_vars' chpwd_functions+="_git_prompt_info" PERIOD=15 periodic_functions+="_git_prompt_info" + +# Prime the pump; this will be executed before PROMPT is defined by the theme, So +# make sure the first prompt when the shell is opened has the git info set +# properly. _git_prompt_info _git_prompt__precmd_update_git_vars() @@ -601,16 +605,23 @@ _git_prompt__precmd_update_git_vars() _git_prompt__preexec_update_git_vars () { case "$1" in - $EDITOR*) __EXECUTED_GIT_COMMAND=1 ;; g*) __EXECUTED_GIT_COMMAND=1 ;; rm*) __EXECUTED_GIT_COMMAND=1 ;; touch*) __EXECUTED_GIT_COMMAND=1 ;; mkdir*) __EXECUTED_GIT_COMMAND=1 ;; echo*) __EXECUTED_GIT_COMMAND=1 ;; + $EDITOR*) + if [[ -n "$EDITOR" ]]; then + __EXECUTED_GIT_COMMAND=1 + fi + ;; esac } #-------------------------------------------------- -git_prompt_info2() { echo $_GIT_PROMPT_INFO } +git_prompt_info2() +{ + echo $_GIT_PROMPT_INFO +}