mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-22 20:31:57 +00:00
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.
This commit is contained in:
parent
15d051c32b
commit
f9d4a067ec
1 changed files with 1 additions and 3 deletions
|
@ -50,9 +50,7 @@ function _ruby_version() {
|
||||||
# use a neutral color, otherwise colors will vary according to time.
|
# use a neutral color, otherwise colors will vary according to time.
|
||||||
function _git_time_since_commit() {
|
function _git_time_since_commit() {
|
||||||
# Only proceed if there is actually a commit.
|
# Only proceed if there is actually a commit.
|
||||||
if git log -1 > /dev/null 2>&1; then
|
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
|
||||||
# Get the last commit.
|
|
||||||
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
|
|
||||||
now=$(date +%s)
|
now=$(date +%s)
|
||||||
seconds_since_last_commit=$((now-last_commit))
|
seconds_since_last_commit=$((now-last_commit))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue