2012-01-31 23:37:51 -05:00
|
|
|
#
|
2012-09-06 23:17:38 -04:00
|
|
|
# Exposes Git repository information via the $git_info associative array.
|
2012-01-31 23:37:51 -05:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
2012-04-03 22:16:40 -04:00
|
|
|
# Usage:
|
|
|
|
# Define the following styles in a prompt theme setup function.
|
|
|
|
#
|
|
|
|
# # %s - Special action name (am, merge, rebase).
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' action 'action:%s'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %a - Indicator to notify of added files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' added 'added:%a'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %A - Indicator to notify of ahead branch.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' ahead 'ahead:%A'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %B - Indicator to notify of behind branch.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' behind 'behind:%B'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %b - Branch name.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' branch 'branch:%b'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
2012-04-11 21:21:11 -04:00
|
|
|
# # %C - Indicator to notify of a clean working directory.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' clean 'clean'
|
2012-04-11 21:21:11 -04:00
|
|
|
#
|
2012-04-03 22:16:40 -04:00
|
|
|
# # %c - SHA-1 hash.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' commit 'commit:%c'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %d - Indicator to notify of deleted files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' deleted 'deleted:%d'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %D - Indicator to notify of dirty files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' dirty 'dirty:%D'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %m - Indicator to notify of modified files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' modified 'modified:%m'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %p - HEAD position in relation to the nearest branch, remote, tag.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' position 'position:%p'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %R - Remote name.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:moduleit' remote 'remote:%R'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %r - Indicator to notify of renamed files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' renamed 'renamed:%r'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %S - Indicator to notify of stashed files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' stashed 'stashed:%S'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
2012-04-04 18:55:15 -04:00
|
|
|
# # %U - Indicator to notify of unmerged files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' unmerged 'unmerged:%U'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # %u - Indicator to notify of untracked files.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' untracked 'untracked:%u'
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
|
|
|
# # Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git:ignore' submodule ''
|
2012-04-03 22:16:40 -04:00
|
|
|
#
|
2012-04-04 18:55:15 -04:00
|
|
|
# # Prompts.
|
2012-09-03 16:08:39 -04:00
|
|
|
# zstyle ':prezto:module:git' info \
|
2012-04-11 21:21:11 -04:00
|
|
|
# 'prompt' ' git:(%b%C%D)' \
|
2012-04-04 18:55:15 -04:00
|
|
|
# 'rprompt' ''
|
|
|
|
#
|
2012-01-31 23:37:51 -05:00
|
|
|
|
2012-04-04 14:46:30 -04:00
|
|
|
# Load dependencies.
|
2012-09-08 19:15:48 -04:00
|
|
|
pmodload 'helper'
|
2012-04-04 14:46:30 -04:00
|
|
|
|
2012-08-27 20:38:23 -04:00
|
|
|
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
2011-09-05 00:37:36 -04:00
|
|
|
# Borrowed from vcs_info and edited.
|
2012-03-23 14:57:51 -04:00
|
|
|
function _git-action {
|
2011-09-05 00:37:36 -04:00
|
|
|
local action_dir
|
2012-05-06 13:40:11 -04:00
|
|
|
local git_dir="$(git-dir)"
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
for action_dir in \
|
|
|
|
"${git_dir}/rebase-apply" \
|
|
|
|
"${git_dir}/rebase" \
|
2012-08-27 21:34:22 -04:00
|
|
|
"${git_dir}/../.dotest"
|
|
|
|
do
|
2011-09-05 00:37:36 -04:00
|
|
|
if [[ -d "$action_dir" ]] ; then
|
|
|
|
if [[ -f "${action_dir}/rebasing" ]] ; then
|
2012-08-27 20:40:15 -04:00
|
|
|
print 'rebase'
|
2011-09-05 00:37:36 -04:00
|
|
|
elif [[ -f "${action_dir}/applying" ]] ; then
|
2012-08-27 20:40:15 -04:00
|
|
|
print 'am'
|
2011-09-05 00:37:36 -04:00
|
|
|
else
|
2012-08-27 20:40:15 -04:00
|
|
|
print 'am/rebase'
|
2011-09-05 00:37:36 -04:00
|
|
|
fi
|
2012-08-27 21:34:22 -04:00
|
|
|
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for action_dir in \
|
|
|
|
"${git_dir}/rebase-merge/interactive" \
|
2012-08-27 21:34:22 -04:00
|
|
|
"${git_dir}/.dotest-merge/interactive"
|
|
|
|
do
|
2011-09-05 00:37:36 -04:00
|
|
|
if [[ -f "$action_dir" ]]; then
|
2011-10-11 23:13:58 -04:00
|
|
|
print 'rebase-i'
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for action_dir in \
|
2012-08-27 22:43:07 -04:00
|
|
|
"${git_dir}/rebase-merge" \
|
2012-08-27 21:34:22 -04:00
|
|
|
"${git_dir}/.dotest-merge"
|
|
|
|
do
|
2011-09-05 00:37:36 -04:00
|
|
|
if [[ -d "$action_dir" ]]; then
|
2011-10-11 23:13:58 -04:00
|
|
|
print 'rebase-m'
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
2011-10-11 23:13:58 -04:00
|
|
|
print 'merge'
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
2012-08-27 20:38:23 -04:00
|
|
|
if [[ -d "${git_dir}/sequencer" ]] ; then
|
|
|
|
print 'cherry-seq'
|
|
|
|
else
|
|
|
|
print 'cherry'
|
|
|
|
fi
|
|
|
|
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
2011-10-11 23:13:58 -04:00
|
|
|
print 'bisect'
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Turns off git-info for the current repository.
|
2012-03-23 14:57:51 -04:00
|
|
|
function _git-info-abort {
|
2012-01-20 22:03:17 -05:00
|
|
|
if ! is-true "$_git_info_executing"; then
|
2011-09-05 00:37:36 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2012-01-19 02:28:01 -05:00
|
|
|
cat >&2 <<EOF
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
|
|
|
|
Gathering status for certain repositories is time intensive.
|
|
|
|
By pressing CTRL + C, you have turned off prompt Git status
|
|
|
|
for this repository.
|
|
|
|
|
|
|
|
To revert, execute:
|
|
|
|
git-info on
|
|
|
|
|
2012-01-19 02:28:01 -05:00
|
|
|
EOF
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
unset _git_info_executing
|
|
|
|
git config --bool prompt.showinfo false
|
|
|
|
git-info
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
add-zsh-trap INT _git-info-abort
|
|
|
|
|
|
|
|
# Gets the Git status information.
|
2012-03-23 14:57:51 -04:00
|
|
|
function git-info {
|
2011-09-05 00:37:36 -04:00
|
|
|
# Extended globbing is needed to parse repository status.
|
2011-10-10 22:16:06 -04:00
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
setopt EXTENDED_GLOB
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
local action
|
|
|
|
local action_format
|
|
|
|
local action_formatted
|
|
|
|
local added=0
|
|
|
|
local added_format
|
|
|
|
local added_formatted
|
|
|
|
local ahead
|
2012-03-14 18:02:16 -04:00
|
|
|
local ahead_and_behind
|
|
|
|
local ahead_and_behind_cmd
|
2011-09-05 00:37:36 -04:00
|
|
|
local ahead_format
|
|
|
|
local ahead_formatted
|
|
|
|
local ahead_or_behind
|
|
|
|
local behind
|
|
|
|
local behind_format
|
|
|
|
local behind_formatted
|
|
|
|
local branch
|
|
|
|
local branch_format
|
|
|
|
local branch_formatted
|
2012-03-14 18:02:16 -04:00
|
|
|
local branch_info
|
2012-04-11 21:21:11 -04:00
|
|
|
local clean
|
|
|
|
local clean_formatted
|
2011-09-05 00:37:36 -04:00
|
|
|
local commit
|
|
|
|
local commit_format
|
2012-03-14 18:02:16 -04:00
|
|
|
local commit_formatted
|
2011-09-05 00:37:36 -04:00
|
|
|
local deleted=0
|
|
|
|
local deleted_format
|
|
|
|
local deleted_formatted
|
2012-03-14 19:13:38 -04:00
|
|
|
local dirty=0
|
|
|
|
local dirty_format
|
2011-09-05 00:37:36 -04:00
|
|
|
local dirty_formatted
|
2012-03-14 18:02:16 -04:00
|
|
|
local ignore_submodule
|
2012-04-04 18:55:15 -04:00
|
|
|
local -A info_formats
|
|
|
|
local info_format
|
2011-09-05 00:37:36 -04:00
|
|
|
local line_number=0
|
|
|
|
local modified=0
|
|
|
|
local modified_format
|
|
|
|
local modified_formatted
|
2012-03-14 18:38:32 -04:00
|
|
|
local position
|
|
|
|
local position_format
|
|
|
|
local position_formatted
|
2011-09-05 00:37:36 -04:00
|
|
|
local remote
|
2012-03-14 18:02:16 -04:00
|
|
|
local remote_cmd
|
2011-09-05 00:37:36 -04:00
|
|
|
local remote_format
|
|
|
|
local remote_formatted
|
|
|
|
local renamed=0
|
|
|
|
local renamed_format
|
|
|
|
local renamed_formatted
|
|
|
|
local stashed=0
|
|
|
|
local stashed_format
|
|
|
|
local stashed_formatted
|
2012-03-14 18:02:16 -04:00
|
|
|
local status_cmd
|
2011-09-05 00:37:36 -04:00
|
|
|
local unmerged=0
|
|
|
|
local unmerged_format
|
|
|
|
local unmerged_formatted
|
|
|
|
local untracked=0
|
|
|
|
local untracked_format
|
|
|
|
local untracked_formatted
|
|
|
|
|
2012-04-04 18:55:15 -04:00
|
|
|
# Clean up previous $git_info.
|
|
|
|
unset git_info
|
|
|
|
typeset -gA git_info
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
# Return if not inside a Git repository work tree.
|
2012-03-14 18:02:16 -04:00
|
|
|
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
2011-09-05 00:37:36 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $# > 0 )); then
|
|
|
|
if [[ "$1" == [Oo][Nn] ]]; then
|
|
|
|
git config --bool prompt.showinfo true
|
|
|
|
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
|
|
|
git config --bool prompt.showinfo false
|
|
|
|
else
|
2012-01-19 02:28:01 -05:00
|
|
|
print "usage: $0 [ on | off ]" >&2
|
2011-09-05 00:37:36 -04:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Return if git-info is disabled.
|
2012-01-20 22:03:17 -05:00
|
|
|
if ! is-true "${$(git config --bool prompt.showinfo):-true}"; then
|
2011-09-05 00:37:36 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Used to abort and turn git-info off on SIGINT.
|
|
|
|
_git_info_executing=true
|
|
|
|
|
2012-03-14 18:02:16 -04:00
|
|
|
# Use porcelain status for easy parsing.
|
|
|
|
status_cmd='git status --porcelain'
|
|
|
|
|
|
|
|
# Gets the remote name.
|
|
|
|
remote_cmd='git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
|
|
|
|
|
|
|
# Gets the commit difference counts between local and remote.
|
|
|
|
ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
|
2012-02-03 19:12:47 -05:00
|
|
|
|
|
|
|
# Ignore submodule status.
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git:ignore' submodule 'ignore_submodule'
|
2012-04-04 14:12:28 -04:00
|
|
|
if [[ -n "$ignore_submodule" ]]; then
|
|
|
|
status_cmd+=" --ignore-submodules=${ignore_submodule}"
|
2012-02-03 19:12:47 -05:00
|
|
|
fi
|
|
|
|
|
2012-03-22 21:26:30 -04:00
|
|
|
# Format commit.
|
2012-03-14 18:02:16 -04:00
|
|
|
commit="$(git rev-parse HEAD 2> /dev/null)"
|
2012-03-22 21:26:30 -04:00
|
|
|
if [[ -n "$commit" ]]; then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' commit 'commit_format'
|
2012-03-22 21:26:30 -04:00
|
|
|
zformat -f commit_formatted "$commit_format" "c:$commit"
|
|
|
|
fi
|
2011-09-05 00:37:36 -04:00
|
|
|
|
2012-03-14 18:02:16 -04:00
|
|
|
# Format stashed.
|
2012-05-06 13:40:11 -04:00
|
|
|
if [[ -f "$(git-dir)/refs/stash" ]]; then
|
2012-05-06 16:48:33 -04:00
|
|
|
stashed="$(git stash list 2> /dev/null | wc -l | awk '{print $1}')"
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' stashed 'stashed_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
|
|
|
|
fi
|
|
|
|
|
2012-03-14 18:02:16 -04:00
|
|
|
# Format action.
|
|
|
|
action="$(_git-action)"
|
|
|
|
if [[ -n "$action" ]]; then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' action 'action_format'
|
2012-03-14 18:02:16 -04:00
|
|
|
zformat -f action_formatted "$action_format" "s:$action"
|
|
|
|
fi
|
2012-03-22 21:26:30 -04:00
|
|
|
|
2012-03-14 18:02:16 -04:00
|
|
|
# Get current status.
|
|
|
|
while IFS=$'\n' read line; do
|
|
|
|
# Count added, deleted, modified, renamed, unmerged, untracked, dirty.
|
|
|
|
# T (type change) is undocumented, see http://git.io/FnpMGw.
|
|
|
|
# For a table of scenarii, see http://i.imgur.com/2YLu1.png.
|
|
|
|
[[ "$line" == ([ACDMT][\ MT]|[ACMT]D)\ * ]] && (( added++ ))
|
|
|
|
[[ "$line" == [\ ACMRT]D\ * ]] && (( deleted++ ))
|
|
|
|
[[ "$line" == ?[MT]\ * ]] && (( modified++ ))
|
|
|
|
[[ "$line" == R?\ * ]] && (( renamed++ ))
|
|
|
|
[[ "$line" == (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
|
|
|
|
[[ "$line" == \?\?\ * ]] && (( untracked++ ))
|
|
|
|
(( dirty++ ))
|
|
|
|
done < <(${(z)status_cmd} 2> /dev/null)
|
2011-09-05 00:37:36 -04:00
|
|
|
|
|
|
|
# Format branch.
|
2012-03-14 18:02:16 -04:00
|
|
|
branch="${$(git symbolic-ref -q HEAD)##refs/heads/}"
|
2012-03-22 21:26:30 -04:00
|
|
|
if [[ -n "$branch" ]]; then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' branch 'branch_format'
|
2012-03-22 21:26:30 -04:00
|
|
|
zformat -f branch_formatted "$branch_format" "b:$branch"
|
2011-09-05 00:37:36 -04:00
|
|
|
|
2012-03-22 21:26:30 -04:00
|
|
|
# Format remote.
|
2012-03-14 18:02:16 -04:00
|
|
|
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
|
|
|
|
if [[ -n "$remote" ]]; then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' remote 'remote_format'
|
2012-03-14 18:02:16 -04:00
|
|
|
zformat -f remote_formatted "$remote_format" "R:$remote"
|
|
|
|
|
|
|
|
# Get ahead and behind counts.
|
|
|
|
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"
|
|
|
|
|
|
|
|
# Format ahead.
|
|
|
|
ahead="$ahead_and_behind[(w)1]"
|
|
|
|
if (( $ahead > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' ahead 'ahead_format'
|
2012-03-14 18:02:16 -04:00
|
|
|
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
|
|
|
|
fi
|
2011-09-05 00:37:36 -04:00
|
|
|
|
2012-03-14 18:02:16 -04:00
|
|
|
# Format behind.
|
|
|
|
behind="$ahead_and_behind[(w)2]"
|
|
|
|
if (( $behind > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' behind 'behind_format'
|
2012-03-14 18:02:16 -04:00
|
|
|
zformat -f behind_formatted "$behind_format" "B:$behind"
|
|
|
|
fi
|
|
|
|
fi
|
2012-03-14 18:38:32 -04:00
|
|
|
else
|
|
|
|
# Format position.
|
|
|
|
position="$(git describe --contains --all HEAD 2> /dev/null)"
|
|
|
|
if [[ -n "$position" ]]; then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' position 'position_format'
|
2012-03-14 18:38:32 -04:00
|
|
|
zformat -f position_formatted "$position_format" "p:$position"
|
|
|
|
fi
|
2011-09-05 00:37:36 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Format added.
|
|
|
|
if (( $added > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' added 'added_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f added_formatted "$added_format" "a:$added_format"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format deleted.
|
|
|
|
if (( $deleted > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' deleted 'deleted_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format modified.
|
|
|
|
if (( $modified > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' modified 'modified_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f modified_formatted "$modified_format" "m:$modified"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format renamed.
|
|
|
|
if (( $renamed > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' renamed 'renamed_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format unmerged.
|
|
|
|
if (( $unmerged > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' unmerged 'unmerged_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Format untracked.
|
|
|
|
if (( $untracked > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' untracked 'untracked_format'
|
2011-09-05 00:37:36 -04:00
|
|
|
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
|
|
|
|
fi
|
|
|
|
|
2012-04-11 21:21:11 -04:00
|
|
|
# Format dirty and clean.
|
|
|
|
if (( $dirty > 0 )); then
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' dirty 'dirty_format'
|
2012-04-11 21:21:11 -04:00
|
|
|
zformat -f dirty_formatted "$dirty_format" "D:$dirty"
|
|
|
|
else
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -s ':prezto:module:git' clean 'clean_formatted'
|
2012-04-11 21:21:11 -04:00
|
|
|
fi
|
2012-03-14 19:13:38 -04:00
|
|
|
|
2012-04-04 18:55:15 -04:00
|
|
|
# Format info.
|
2012-09-03 16:08:39 -04:00
|
|
|
zstyle -a ':prezto:module:git' info 'info_formats'
|
2012-04-04 18:55:15 -04:00
|
|
|
for info_format in ${(k)info_formats}; do
|
|
|
|
zformat -f REPLY "$info_formats[$info_format]" \
|
2011-09-05 00:37:36 -04:00
|
|
|
"A:$ahead_formatted" \
|
|
|
|
"B:$behind_formatted" \
|
2012-03-14 18:38:32 -04:00
|
|
|
"D:$dirty_formatted" \
|
|
|
|
"R:$remote_formatted" \
|
|
|
|
"S:$stashed_formatted" \
|
|
|
|
"U:$unmerged_formatted" \
|
|
|
|
"a:$added_formatted" \
|
2011-09-05 00:37:36 -04:00
|
|
|
"b:$branch_formatted" \
|
2012-04-11 21:21:11 -04:00
|
|
|
"C:$clean_formatted" \
|
2011-09-05 00:37:36 -04:00
|
|
|
"c:$commit_formatted" \
|
|
|
|
"d:$deleted_formatted" \
|
|
|
|
"m:$modified_formatted" \
|
2012-03-14 18:38:32 -04:00
|
|
|
"p:$position_formatted" \
|
2011-09-05 00:37:36 -04:00
|
|
|
"r:$renamed_formatted" \
|
2012-03-14 18:38:32 -04:00
|
|
|
"s:$action_formatted" \
|
2011-09-05 00:37:36 -04:00
|
|
|
"u:$untracked_formatted"
|
2012-04-04 18:55:15 -04:00
|
|
|
git_info[$info_format]="$REPLY"
|
2011-09-05 00:37:36 -04:00
|
|
|
done
|
|
|
|
|
2012-04-04 18:55:15 -04:00
|
|
|
unset REPLY
|
2011-09-05 00:37:36 -04:00
|
|
|
unset _git_info_executing
|
2012-04-04 18:55:15 -04:00
|
|
|
|
2011-09-05 00:37:36 -04:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-10-11 23:13:58 -04:00
|
|
|
git-info "$@"
|
|
|
|
|