1
0
Fork 0

Add different describe commands

pull/74/head
Colin Hebert 13 years ago
parent 27b617bce5
commit 1593dd43b9

@ -143,6 +143,7 @@ function git-info {
local modified_format local modified_format
local modified_formatted local modified_formatted
local position local position
local position_cmd
local position_format local position_format
local position_formatted local position_formatted
local prompt_format local prompt_format
@ -204,6 +205,20 @@ function git-info {
# Gets the commit difference counts between local and remote. # Gets the commit difference counts between local and remote.
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}' ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
# Use describe to get the current position
zstyle -s 'omz:plugin:git:prompt:position' style 'position_style'
case "$position_style" in
(contains)
position_cmd='git describe --contains --tags HEAD'
;;
(references)
position_cmd='git describe --contains --all HEAD'
;;
(tags)
position_cmd='git describe --tags HEAD'
;;
esac
# Ignore submodule status. # Ignore submodule status.
zstyle -b \ zstyle -b \
':omz:plugin:git:prompt:ignore' submodule 'ignore_submodule' ':omz:plugin:git:prompt:ignore' submodule 'ignore_submodule'
@ -279,7 +294,7 @@ function git-info {
fi fi
else else
# Format position. # Format position.
position="$(git describe --contains --all HEAD 2> /dev/null)" position="$(${(z)position_cmd} 2> /dev/null)"
if [[ -n "$position" ]]; then if [[ -n "$position" ]]; then
zstyle -s ':omz:plugin:git:prompt' position 'position_format' zstyle -s ':omz:plugin:git:prompt' position 'position_format'
zformat -f position_formatted "$position_format" "p:$position" zformat -f position_formatted "$position_format" "p:$position"

@ -56,6 +56,9 @@ zstyle ':omz:plugin:git:prompt' prompt ' git:(%b %D)'
# Right prompt. # Right prompt.
zstyle ':omz:plugin:git:prompt' rprompt '' zstyle ':omz:plugin:git:prompt' rprompt ''
# Position style "contains", "references", "tags"
zstyle ':omz:plugin:git:prompt:position' style 'references'
# Ignore submodule. # Ignore submodule.
zstyle ':omz:plugin:git:prompt:ignore' submodule 'no' zstyle ':omz:plugin:git:prompt:ignore' submodule 'no'

Loading…
Cancel
Save