1
0
Fork 0

[Fix #244] Add Git special action styles

pull/298/head
Sorin Ionescu 12 years ago
parent 4f607bb470
commit cfc95cd5ee

@ -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
@ -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.

@ -10,6 +10,14 @@
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" \
@ -17,12 +25,15 @@ function _git-action {
"${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
@ -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
@ -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

Loading…
Cancel
Save