1
0
Fork 0

Add a style that shows a commit relative to a tag/branch

Add a new style in the git plugin to get a commit name based on the closest branch/tag
pull/39/head
Colin Hebert 13 years ago
parent bf27bc1e3b
commit 6955252281

@ -145,6 +145,10 @@ function git-info {
local deleted=0
local deleted_format
local deleted_formatted
local describe
local describe_cmd
local describe_format
local describe_formatted
local dirty=0
local dirty_format
local dirty_formatted
@ -213,6 +217,9 @@ function git-info {
# Gets the commit difference counts between local and remote.
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
# Use describe for approximative branch naming
describe_cmd='git describe --contains --all HEAD'
# Ignore submodule status.
zstyle -b \
':omz:plugin:git:prompt:ignore' submodule 'ignore_submodule'
@ -286,6 +293,13 @@ function git-info {
zformat -f behind_formatted "$behind_format" "B:$behind"
fi
fi
else
# Format describe.
describe=$(${(z)describe_cmd} 2>/dev/null)
if [[ -n "$describe" ]]; then
zstyle -s ':omz:plugin:git:prompt' describe 'describe_format'
zformat -f describe_formatted "$describe_format" "i:$describe"
fi
fi
# Format added.
@ -349,6 +363,7 @@ function git-info {
"c:$commit_formatted" \
"d:$deleted_formatted" \
"D:$dirty_formatted" \
"i:$describe_formatted" \
"m:$modified_formatted" \
"R:$remote_formatted" \
"r:$renamed_formatted" \

@ -29,6 +29,9 @@ zstyle ':omz:plugin:git:prompt' deleted 'deleted:%d'
# %D - Indicator to notify of dirty files.
zstyle ':omz:plugin:git:prompt' dirty 'dirty:%D'
# %i - Closest branch/tag to the commit
zstyle ':omz:plugin:git:prompt' describe '(%i)'
# %m - Indicator to notify of modified files.
zstyle ':omz:plugin:git:prompt' modified 'modified:%m'

Loading…
Cancel
Save