diff --git a/plugins/git/functions/git-info b/plugins/git/functions/git-info index 2b75467a..b5cfd33f 100644 --- a/plugins/git/functions/git-info +++ b/plugins/git/functions/git-info @@ -142,6 +142,9 @@ function git-info { local modified=0 local modified_format local modified_formatted + local position + local position_format + local position_formatted local prompt_format local remote local remote_cmd @@ -274,6 +277,13 @@ function git-info { zformat -f behind_formatted "$behind_format" "B:$behind" fi fi + else + # Format position. + position="$(git describe --contains --all HEAD 2> /dev/null)" + if [[ -n "$position" ]]; then + zstyle -s ':omz:plugin:git:prompt' position 'position_format' + zformat -f position_formatted "$position_format" "p:$position" + fi fi # Format added. @@ -329,19 +339,20 @@ function git-info { for git_info_var in ${(k)git_info_vars}; do zformat -f "$git_info_var" "$git_info_vars[$git_info_var]" \ - "s:$action_formatted" \ - "a:$added_formatted" \ "A:$ahead_formatted" \ "B:$behind_formatted" \ + "D:$dirty_formatted" \ + "R:$remote_formatted" \ + "S:$stashed_formatted" \ + "U:$unmerged_formatted" \ + "a:$added_formatted" \ "b:$branch_formatted" \ "c:$commit_formatted" \ "d:$deleted_formatted" \ - "D:$dirty_formatted" \ "m:$modified_formatted" \ - "R:$remote_formatted" \ + "p:$position_formatted" \ "r:$renamed_formatted" \ - "S:$stashed_formatted" \ - "U:$unmerged_formatted" \ + "s:$action_formatted" \ "u:$untracked_formatted" done diff --git a/plugins/git/style.zsh b/plugins/git/style.zsh index 6c4324a7..d1196ef4 100644 --- a/plugins/git/style.zsh +++ b/plugins/git/style.zsh @@ -32,6 +32,9 @@ zstyle ':omz:plugin:git:prompt' dirty 'dirty:%D' # %m - Indicator to notify of modified files. zstyle ':omz:plugin:git:prompt' modified 'modified:%m' +# %p - HEAD position in relation to the nearest branch, remote, tag. +zstyle ':omz:plugin:git:prompt' position '%p' + # %R - Remote name. zstyle ':omz:plugin:git:prompt' remote '%R'