Shorten git zstyle namespace

This commit is contained in:
Sorin Ionescu 2012-04-03 00:29:43 -04:00
parent 900c4d8f3f
commit 48dcd2f723
3 changed files with 52 additions and 52 deletions

View File

@ -206,9 +206,9 @@ function git-info {
# Ignore submodule status. # Ignore submodule status.
zstyle -b \ zstyle -b \
':omz:module:git:prompt:ignore' submodule 'ignore_submodule' ':omz:module:git:ignore' submodule 'ignore_submodule'
zstyle -s \ zstyle -s \
':omz:module:git:prompt:ignore:submodule' when 'ignore_submodule_when' ':omz:module:git:ignore:submodule' when 'ignore_submodule_when'
if is-true "$ignore_submodule"; then if is-true "$ignore_submodule"; then
status_cmd+=" --ignore-submodules=${ignore_submodule_when:-all}" status_cmd+=" --ignore-submodules=${ignore_submodule_when:-all}"
fi fi
@ -216,21 +216,21 @@ function git-info {
# Format commit. # Format commit.
commit="$(git rev-parse HEAD 2> /dev/null)" commit="$(git rev-parse HEAD 2> /dev/null)"
if [[ -n "$commit" ]]; then if [[ -n "$commit" ]]; then
zstyle -s ':omz:module:git:prompt' commit 'commit_format' zstyle -s ':omz:module:git' commit 'commit_format'
zformat -f commit_formatted "$commit_format" "c:$commit" zformat -f commit_formatted "$commit_format" "c:$commit"
fi fi
# Format stashed. # Format stashed.
if [[ -f "$(_git-dir)/refs/stash" ]]; then if [[ -f "$(_git-dir)/refs/stash" ]]; then
stashed="$(git stash list 2> /dev/null | wc -l)" stashed="$(git stash list 2> /dev/null | wc -l)"
zstyle -s ':omz:module:git:prompt' stashed 'stashed_format' zstyle -s ':omz:module:git' stashed 'stashed_format'
zformat -f stashed_formatted "$stashed_format" "S:$stashed" zformat -f stashed_formatted "$stashed_format" "S:$stashed"
fi fi
# Format action. # Format action.
action="$(_git-action)" action="$(_git-action)"
if [[ -n "$action" ]]; then if [[ -n "$action" ]]; then
zstyle -s ':omz:module:git:prompt' action 'action_format' zstyle -s ':omz:module:git' action 'action_format'
zformat -f action_formatted "$action_format" "s:$action" zformat -f action_formatted "$action_format" "s:$action"
fi fi
@ -251,13 +251,13 @@ function git-info {
# Format branch. # Format branch.
branch="${$(git symbolic-ref -q HEAD)##refs/heads/}" branch="${$(git symbolic-ref -q HEAD)##refs/heads/}"
if [[ -n "$branch" ]]; then if [[ -n "$branch" ]]; then
zstyle -s ':omz:module:git:prompt' branch 'branch_format' zstyle -s ':omz:module:git' branch 'branch_format'
zformat -f branch_formatted "$branch_format" "b:$branch" zformat -f branch_formatted "$branch_format" "b:$branch"
# Format remote. # Format remote.
remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}" remote="${$(${(z)remote_cmd} 2> /dev/null)##refs/remotes/}"
if [[ -n "$remote" ]]; then if [[ -n "$remote" ]]; then
zstyle -s ':omz:module:git:prompt' remote 'remote_format' zstyle -s ':omz:module:git' remote 'remote_format'
zformat -f remote_formatted "$remote_format" "R:$remote" zformat -f remote_formatted "$remote_format" "R:$remote"
# Get ahead and behind counts. # Get ahead and behind counts.
@ -266,14 +266,14 @@ function git-info {
# Format ahead. # Format ahead.
ahead="$ahead_and_behind[(w)1]" ahead="$ahead_and_behind[(w)1]"
if (( $ahead > 0 )); then if (( $ahead > 0 )); then
zstyle -s ':omz:module:git:prompt' ahead 'ahead_format' zstyle -s ':omz:module:git' ahead 'ahead_format'
zformat -f ahead_formatted "$ahead_format" "A:$ahead" zformat -f ahead_formatted "$ahead_format" "A:$ahead"
fi fi
# Format behind. # Format behind.
behind="$ahead_and_behind[(w)2]" behind="$ahead_and_behind[(w)2]"
if (( $behind > 0 )); then if (( $behind > 0 )); then
zstyle -s ':omz:module:git:prompt' behind 'behind_format' zstyle -s ':omz:module:git' behind 'behind_format'
zformat -f behind_formatted "$behind_format" "B:$behind" zformat -f behind_formatted "$behind_format" "B:$behind"
fi fi
fi fi
@ -281,56 +281,56 @@ function git-info {
# Format position. # Format position.
position="$(git describe --contains --all HEAD 2> /dev/null)" position="$(git describe --contains --all HEAD 2> /dev/null)"
if [[ -n "$position" ]]; then if [[ -n "$position" ]]; then
zstyle -s ':omz:plugin:git:prompt' position 'position_format' zstyle -s ':omz:module:git:prompt' position 'position_format'
zformat -f position_formatted "$position_format" "p:$position" zformat -f position_formatted "$position_format" "p:$position"
fi fi
fi fi
# Format added. # Format added.
if (( $added > 0 )); then if (( $added > 0 )); then
zstyle -s ':omz:module:git:prompt' added 'added_format' zstyle -s ':omz:module:git' added 'added_format'
zformat -f added_formatted "$added_format" "a:$added_format" zformat -f added_formatted "$added_format" "a:$added_format"
fi fi
# Format deleted. # Format deleted.
if (( $deleted > 0 )); then if (( $deleted > 0 )); then
zstyle -s ':omz:module:git:prompt' deleted 'deleted_format' zstyle -s ':omz:module:git' deleted 'deleted_format'
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format" zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
fi fi
# Format modified. # Format modified.
if (( $modified > 0 )); then if (( $modified > 0 )); then
zstyle -s ':omz:module:git:prompt' modified 'modified_format' zstyle -s ':omz:module:git' modified 'modified_format'
zformat -f modified_formatted "$modified_format" "m:$modified" zformat -f modified_formatted "$modified_format" "m:$modified"
fi fi
# Format renamed. # Format renamed.
if (( $renamed > 0 )); then if (( $renamed > 0 )); then
zstyle -s ':omz:module:git:prompt' renamed 'renamed_format' zstyle -s ':omz:module:git' renamed 'renamed_format'
zformat -f renamed_formatted "$renamed_format" "r:$renamed" zformat -f renamed_formatted "$renamed_format" "r:$renamed"
fi fi
# Format unmerged. # Format unmerged.
if (( $unmerged > 0 )); then if (( $unmerged > 0 )); then
zstyle -s ':omz:module:git:prompt' unmerged 'unmerged_format' zstyle -s ':omz:module:git' unmerged 'unmerged_format'
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged" zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
fi fi
# Format untracked. # Format untracked.
if (( $untracked > 0 )); then if (( $untracked > 0 )); then
zstyle -s ':omz:module:git:prompt' untracked 'untracked_format' zstyle -s ':omz:module:git' untracked 'untracked_format'
zformat -f untracked_formatted "$untracked_format" "u:$untracked" zformat -f untracked_formatted "$untracked_format" "u:$untracked"
fi fi
# Format dirty. # Format dirty.
if (( $dirty > 0 )); then if (( $dirty > 0 )); then
zstyle -s ':omz:module:git:prompt' dirty 'dirty_format' zstyle -s ':omz:module:git' dirty 'dirty_format'
zformat -f dirty_formatted "$dirty_format" "D:$dirty" zformat -f dirty_formatted "$dirty_format" "D:$dirty"
fi fi
# Format prompts. # Format prompts.
zstyle -s ':omz:module:git:prompt' prompt 'prompt_format' zstyle -s ':omz:module:git' prompt 'prompt_format'
zstyle -s ':omz:module:git:prompt' rprompt 'rprompt_format' zstyle -s ':omz:module:git' rprompt 'rprompt_format'
git_info_vars=( git_info_vars=(
git_prompt_info "$prompt_format" git_prompt_info "$prompt_format"

View File

@ -6,59 +6,59 @@
# #
# %s - Special action name (am, merge, rebase). # %s - Special action name (am, merge, rebase).
zstyle ':omz:module:git:prompt' action 'action:%s' zstyle ':omz:module:git' action 'action:%s'
# %a - Indicator to notify of added files. # %a - Indicator to notify of added files.
zstyle ':omz:module:git:prompt' added 'added:%a' zstyle ':omz:module:git' added 'added:%a'
# %A - Indicator to notify of ahead branch. # %A - Indicator to notify of ahead branch.
zstyle ':omz:module:git:prompt' ahead 'ahead:%A' zstyle ':omz:module:git' ahead 'ahead:%A'
# %B - Indicator to notify of behind branch. # %B - Indicator to notify of behind branch.
zstyle ':omz:module:git:prompt' behind 'behind:%B' zstyle ':omz:module:git' behind 'behind:%B'
# %b - Branch name. # %b - Branch name.
zstyle ':omz:module:git:prompt' branch 'branch:%b' zstyle ':omz:module:git' branch 'branch:%b'
# %c - SHA-1 hash. # %c - SHA-1 hash.
zstyle ':omz:module:git:prompt' commit 'commit:%c' zstyle ':omz:module:git' commit 'commit:%c'
# %d - Indicator to notify of deleted files. # %d - Indicator to notify of deleted files.
zstyle ':omz:module:git:prompt' deleted 'deleted:%d' zstyle ':omz:module:git' deleted 'deleted:%d'
# %D - Indicator to notify of dirty files. # %D - Indicator to notify of dirty files.
zstyle ':omz:module:git:prompt' dirty 'dirty:%D' zstyle ':omz:module:git' dirty 'dirty:%D'
# %m - Indicator to notify of modified files. # %m - Indicator to notify of modified files.
zstyle ':omz:module:git:prompt' modified 'modified:%m' zstyle ':omz:module:git' modified 'modified:%m'
# %p - HEAD position in relation to the nearest branch, remote, tag. # %p - HEAD position in relation to the nearest branch, remote, tag.
zstyle ':omz:module:git:prompt' position 'position:%p' zstyle ':omz:module:git:prompt' position 'position:%p'
# %R - Remote name. # %R - Remote name.
zstyle ':omz:module:git:prompt' remote 'remote:%R' zstyle ':omz:module:git' remote 'remote:%R'
# %r - Indicator to notify of renamed files. # %r - Indicator to notify of renamed files.
zstyle ':omz:module:git:prompt' renamed 'renamed:%r' zstyle ':omz:module:git' renamed 'renamed:%r'
# %S - Indicator to notify of stashed files. # %S - Indicator to notify of stashed files.
zstyle ':omz:module:git:prompt' stashed 'stashed:%S' zstyle ':omz:module:git' stashed 'stashed:%S'
# %U - Indicator to notify of unmerged files. # %U - Indicator to notify of unmerged files.
zstyle ':omz:module:git:prompt' unmerged 'unmerged:%U' zstyle ':omz:module:git' unmerged 'unmerged:%U'
# %u - Indicator to notify of untracked files. # %u - Indicator to notify of untracked files.
zstyle ':omz:module:git:prompt' untracked 'untracked:%u' zstyle ':omz:module:git' untracked 'untracked:%u'
# Left prompt. # Left prompt.
zstyle ':omz:module:git:prompt' prompt ' git:(%b %D)' zstyle ':omz:module:git' prompt ' git:(%b %D)'
# Right prompt. # Right prompt.
zstyle ':omz:module:git:prompt' rprompt '' zstyle ':omz:module:git' rprompt ''
# Ignore submodule. # Ignore submodule.
zstyle ':omz:module:git:prompt:ignore' submodule 'no' zstyle ':omz:module:git:ignore' submodule 'no'
# Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'. # Ignore submodule when it is 'dirty', 'untracked', 'all', or 'none'.
zstyle ':omz:module:git:prompt:ignore:submodule' when 'all' zstyle ':omz:module:git:ignore:submodule' when 'all'

View File

@ -28,21 +28,21 @@ function prompt_sorin_setup {
zstyle ':omz:module:editor' completing '%B%F{red}...%f%b' zstyle ':omz:module:editor' completing '%B%F{red}...%f%b'
zstyle ':omz:module:editor:keymap' primary '' zstyle ':omz:module:editor:keymap' primary ''
zstyle ':omz:module:editor:keymap' alternate ' %F{yellow}%f%B%F{red}%f%b%F{red}%f' zstyle ':omz:module:editor:keymap' alternate ' %F{yellow}%f%B%F{red}%f%b%F{red}%f'
zstyle ':omz:module:git:prompt' action ':%%B%F{yellow}%s%f%%b' zstyle ':omz:module:git' action ':%%B%F{yellow}%s%f%%b'
zstyle ':omz:module:git:prompt' added ' %%B%F{green}✚%f%%b' zstyle ':omz:module:git' added ' %%B%F{green}✚%f%%b'
zstyle ':omz:module:git:prompt' ahead ' %%B%F{yellow}⬆%f%%b' zstyle ':omz:module:git' ahead ' %%B%F{yellow}⬆%f%%b'
zstyle ':omz:module:git:prompt' behind ' %%B%F{yellow}⬇%f%%b' zstyle ':omz:module:git' behind ' %%B%F{yellow}⬇%f%%b'
zstyle ':omz:module:git:prompt' branch ':%F{red}%b%f' zstyle ':omz:module:git' branch ':%F{red}%b%f'
zstyle ':omz:module:git:prompt' commit ':%F{green}%.7c%f' zstyle ':omz:module:git' commit ':%F{green}%.7c%f'
zstyle ':omz:module:git:prompt' deleted ' %%B%F{red}✖%f%%b' zstyle ':omz:module:git' deleted ' %%B%F{red}✖%f%%b'
zstyle ':omz:module:git:prompt' modified ' %%B%F{blue}✱%f%%b' zstyle ':omz:module:git' modified ' %%B%F{blue}✱%f%%b'
zstyle ':omz:module:git:prompt' position ':%F{green}%p%f' zstyle ':omz:module:git' position ':%F{green}%p%f'
zstyle ':omz:module:git:prompt' renamed ' %%B%F{magenta}➜%f%%b' zstyle ':omz:module:git' renamed ' %%B%F{magenta}➜%f%%b'
zstyle ':omz:module:git:prompt' stashed ' %%B%F{cyan}✭%f%%b' zstyle ':omz:module:git' stashed ' %%B%F{cyan}✭%f%%b'
zstyle ':omz:module:git:prompt' unmerged ' %%B%F{yellow}═%f%%b' zstyle ':omz:module:git' unmerged ' %%B%F{yellow}═%f%%b'
zstyle ':omz:module:git:prompt' untracked ' %%B%F{white}◼%f%%b' zstyle ':omz:module:git' untracked ' %%B%F{white}◼%f%%b'
zstyle ':omz:module:git:prompt' prompt ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s' zstyle ':omz:module:git' prompt ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s'
zstyle ':omz:module:git:prompt' rprompt '%A%B%S%a%d%m%r%U%u' zstyle ':omz:module:git' rprompt '%A%B%S%a%d%m%r%U%u'
PROMPT='%F{cyan}%1~%f${(e)git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}%f%b) ' PROMPT='%F{cyan}%1~%f${(e)git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}%f%b) '
RPROMPT='${editor_keymap_info}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}' RPROMPT='${editor_keymap_info}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}'