Improved the _git_time_since_commit
function.
Check for at least one commit using a `git log` limit of one. Improves the performance inside git repos with a large history.
This commit is contained in:
parent
729b19c085
commit
de56943a0e
@ -38,9 +38,8 @@ function _ruby_version() {
|
|||||||
# Determine the time since last commit. If branch is clean,
|
# Determine the time since last commit. If branch is clean,
|
||||||
# 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() {
|
||||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
# 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 [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
|
|
||||||
# Get the last commit.
|
# Get the last commit.
|
||||||
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
|
last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
|
||||||
now=$(date +%s)
|
now=$(date +%s)
|
||||||
@ -66,7 +65,6 @@ function _git_time_since_commit() {
|
|||||||
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
|
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
|
||||||
echo "$color$commit_age%{$reset_color%}"
|
echo "$color$commit_age%{$reset_color%}"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $USER == "root" ]]; then
|
if [[ $USER == "root" ]]; then
|
||||||
@ -99,4 +97,3 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
|
|||||||
export LSCOLORS="exfxcxdxbxegedabagacad"
|
export LSCOLORS="exfxcxdxbxegedabagacad"
|
||||||
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
|
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
|
||||||
export GREP_COLOR='1;33'
|
export GREP_COLOR='1;33'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user