summaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authorCory Snider <corhere@gmail.com>2018-04-15 08:45:58 -0400
committerMarc Cornellà <marc.cornella@live.com>2018-04-15 14:45:58 +0200
commitf9d4a067ecb9d3fa65326e5e6a76649ccf65434c (patch)
treec3b44307b82832616e758de8dd9c0f85e37d7639 /themes
parent15d051c32b1b11d37b38c5f3e7a1491c4d859db0 (diff)
downloadzsh-f9d4a067ecb9d3fa65326e5e6a76649ccf65434c.tar.gz
zsh-f9d4a067ecb9d3fa65326e5e6a76649ccf65434c.tar.bz2
zsh-f9d4a067ecb9d3fa65326e5e6a76649ccf65434c.zip
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.
Diffstat (limited to 'themes')
-rw-r--r--themes/avit.zsh-theme4
1 files changed, 1 insertions, 3 deletions
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 4f0dcbcc6..c43fcc9fe 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -50,9 +50,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))