Reduce number of git calls when displaying prompt (#3795)
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.
Diff
1diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
2index 4f0dcbcc688fe56ccb9300a33047cfdc1df0fbe0..c43fcc9feafae6de20d55f0d2015ab077711e2e3 100644
3--- a/themes/avit.zsh-theme
4+++ b/themes/avit.zsh-theme
5@@ -50,9 +50,7 @@ function _ruby_version() {
6 # use a neutral color, otherwise colors will vary according to time.
7 function _git_time_since_commit() {
8 # Only proceed if there is actually a commit.
9- if git log -1 > /dev/null 2>&1; then
10- # Get the last commit.
11- last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
12+ if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
13 now=$(date +%s)
14 seconds_since_last_commit=$((now-last_commit))
15