From d79e7d507392742cbdb3895b2ea4dd1516ba2f5d Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Mon, 20 Apr 2015 11:47:14 -0400 Subject: [PATCH] Reduce number of git calls when displaying prompt The avit theme's _git_time_since_commit function was running git twice. Reduce it with a single call to `git log`, checking the exit code for success. --- themes/avit.zsh-theme | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 65466b82f..201cee93f 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -39,9 +39,7 @@ function _ruby_version() { # use a neutral color, otherwise colors will vary according to time. function _git_time_since_commit() { # Only proceed if there is actually a commit. - if git log -1 > /dev/null 2>&1; then - # Get the last commit. - last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null) + if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then now=$(date +%s) seconds_since_last_commit=$((now-last_commit))