Skip to content

Commit

Permalink
[Fix sorin-ionescu#244] Add Git special action styles
Browse files Browse the repository at this point in the history
  • Loading branch information
RIT80 authored and RIT80 committed Oct 2, 2012
1 parent c3ab941 commit 702957f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
20 changes: 18 additions & 2 deletions modules/git/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,12 @@ Theming
-------

To display information about the current repository in a prompt, define the
following styles in the `prompt_name_setup` function.
following styles in the `prompt_name_setup` function, where the syntax for
setting a style is as follows.

| Name | Format Code | Content
zstyle ':prezto:module:git:info:context:subcontext' format 'string'

| Name | Format Code | Description
| --------- | :---------: | ---------------------------------------------------
| action | %s | Special action name
| added | %a | Added files count
Expand All @@ -261,6 +264,19 @@ following styles in the `prompt_name_setup` function.
| stashed | %S | Stashed states count
| unmerged | %U | Unmerged files count
| untracked | %u | Untracked files count
[**Main Contexts**]

| Name | Format | Description
| -------------------- | :---------: | -----------------------------------------
| apply | value | Applying patches
| bisect | value | Binary searching for changes
| cherry-pick | value | Cherry picking
| cherry-pick-sequence | value | Cherry picking sequence
| merge | value | Merging
| rebase | value | Rebasing
| rebase-interactive | value | Rebasing interactively
| rebase-merge | value | Rebasing merge
[**Special Action Contexts**]

First, format the repository state attributes. For example, to format the branch
and remote names, define the following styles.
Expand Down
35 changes: 26 additions & 9 deletions modules/git/functions/git-info
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,30 @@
function _git-action {
local action_dir
local git_dir="$(git-dir)"
local apply_formatted
local bisect_formatted
local cherry_pick_formatted
local cherry_pick_sequence_formatted
local merge_formatted
local rebase_formatted
local rebase_interactive_formatted
local rebase_merge_formatted

for action_dir in \
"${git_dir}/rebase-apply" \
"${git_dir}/rebase" \
"${git_dir}/../.dotest"
do
if [[ -d "$action_dir" ]] ; then
zstyle -s ':prezto:module:git:info:action:apply' format 'apply_formatted' || apply_formatted='apply'
zstyle -s ':prezto:module:git:info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'

if [[ -f "${action_dir}/rebasing" ]] ; then
print 'rebase'
print "$rebase_formatted"
elif [[ -f "${action_dir}/applying" ]] ; then
print 'am'
print "$apply_formatted"
else
print 'am/rebase'
print "${rebase_formatted}/${apply_formatted}"
fi

return 0
Expand All @@ -34,7 +45,8 @@ function _git-action {
"${git_dir}/.dotest-merge/interactive"
do
if [[ -f "$action_dir" ]]; then
print 'rebase-i'
zstyle -s ':prezto:module:git:info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
print "$rebase_interactive_formatted"
return 0
fi
done
Expand All @@ -44,28 +56,33 @@ function _git-action {
"${git_dir}/.dotest-merge"
do
if [[ -d "$action_dir" ]]; then
print 'rebase-m'
zstyle -s ':prezto:module:git:info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
print "$rebase_merge_formatted"
return 0
fi
done

if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
print 'merge'
zstyle -s ':prezto:module:git:info:action:merge' format 'merge_formatted' || merge_formatted='merge'
print "$merge_formatted"
return 0
fi

if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
if [[ -d "${git_dir}/sequencer" ]] ; then
print 'cherry-seq'
zstyle -s ':prezto:module:git:info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
print "$cherry_pick_sequence_formatted"
else
print 'cherry'
zstyle -s ':prezto:module:git:info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
print "$cherry_pick_formatted"
fi

return 0
fi

if [[ -f "${git_dir}/BISECT_LOG" ]]; then
print 'bisect'
zstyle -s ':prezto:module:git:info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
print "$bisect_formatted"
return 0
fi

Expand Down

0 comments on commit 702957f

Please sign in to comment.