1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-06-14 08:41:43 +00:00

Use zstyle instead of variables for configuration.

This commit is contained in:
Sorin Ionescu
2011-12-26 13:37:53 -05:00
parent 60f39d8d91
commit f0499b76c3
13 changed files with 156 additions and 103 deletions

View File

@ -174,18 +174,18 @@ function git-info() {
# Format commit (short).
commit_short="$commit[1,7]"
zstyle -s ':git-info:' commit commit_format
zstyle -s ':omz:plugin:git:prompt' commit commit_format
zformat -f commit_formatted "$commit_format" "c:$commit_short"
# Stashed
if [[ -f "$(git-root)/.git/refs/stash" ]]; then
stashed="$(git stash list 2>/dev/null | wc -l)"
zstyle -s ':git-info:' stashed stashed_format
zstyle -s ':omz:plugin:git:prompt' stashed stashed_format
zformat -f stashed_formatted "$stashed_format" "S:$stashed"
fi
# Assume that the working copy is clean.
zstyle -s ':git-info:' clean clean_formatted
zstyle -s ':omz:plugin:git:prompt' clean clean_formatted
while IFS=$'\n' read line; do
(( line_number++ ))
@ -197,7 +197,7 @@ function git-info() {
# Get action.
action="$(_git-action)"
if [[ -n "$action" ]]; then
zstyle -s ':git-info:' action action_format
zstyle -s ':omz:plugin:git:prompt' action action_format
zformat -f action_formatted "$action_format" "s:$action"
fi
elif (( line_number == 1 )) \
@ -231,7 +231,7 @@ function git-info() {
fi
else
# Format dirty.
[[ -z "$dirty" ]] && zstyle -s ':git-info:' dirty dirty_formatted && unset clean_formatted
[[ -z "$dirty" ]] && zstyle -s ':omz:plugin:git:prompt' dirty dirty_formatted && unset clean_formatted
# Count: added/deleted/modified/renamed/unmerged/untracked
[[ "$line" == (((A|M|D|T) )|(AD|AM|AT|MM))\ * ]] && (( added++ ))
@ -244,7 +244,7 @@ function git-info() {
done < <(git status --short --branch 2> /dev/null)
# Format branch.
zstyle -s ':git-info:' branch branch_format
zstyle -s ':omz:plugin:git:prompt' branch branch_format
zformat -f branch_formatted "$branch_format" "b:$branch"
# Format remote.
@ -252,61 +252,61 @@ function git-info() {
[[ -z $remote ]] \
&& remote=${$(git rev-parse --verify ${branch}@{upstream} \
--symbolic-full-name 2> /dev/null)#refs/remotes/}
zstyle -s ':git-info:' remote remote_format
zstyle -s ':omz:plugin:git:prompt' remote remote_format
zformat -f remote_formatted "$remote_format" "R:$remote"
fi
# Format ahead.
if [[ -n "$ahead" ]]; then
zstyle -s ':git-info:' ahead ahead_format
zstyle -s ':omz:plugin:git:prompt' ahead ahead_format
zformat -f ahead_formatted "$ahead_format" "A:$ahead"
fi
# Format behind.
if [[ -n "$behind" ]]; then
zstyle -s ':git-info:' behind behind_format
zstyle -s ':omz:plugin:git:prompt' behind behind_format
zformat -f behind_formatted "$behind_format" "B:$behind"
fi
# Format added.
if (( $added > 0 )); then
zstyle -s ':git-info:' added added_format
zstyle -s ':omz:plugin:git:prompt' added added_format
zformat -f added_formatted "$added_format" "a:$added_format"
fi
# Format deleted.
if (( $deleted > 0 )); then
zstyle -s ':git-info:' deleted deleted_format
zstyle -s ':omz:plugin:git:prompt' deleted deleted_format
zformat -f deleted_formatted "$deleted_format" "d:$deleted_format"
fi
# Format modified.
if (( $modified > 0 )); then
zstyle -s ':git-info:' modified modified_format
zstyle -s ':omz:plugin:git:prompt' modified modified_format
zformat -f modified_formatted "$modified_format" "m:$modified"
fi
# Format renamed.
if (( $renamed > 0 )); then
zstyle -s ':git-info:' renamed renamed_format
zstyle -s ':omz:plugin:git:prompt' renamed renamed_format
zformat -f renamed_formatted "$renamed_format" "r:$renamed"
fi
# Format unmerged.
if (( $unmerged > 0 )); then
zstyle -s ':git-info:' unmerged unmerged_format
zstyle -s ':omz:plugin:git:prompt' unmerged unmerged_format
zformat -f unmerged_formatted "$unmerged_format" "U:$unmerged"
fi
# Format untracked.
if (( $untracked > 0 )); then
zstyle -s ':git-info:' untracked untracked_format
zstyle -s ':omz:plugin:git:prompt' untracked untracked_format
zformat -f untracked_formatted "$untracked_format" "u:$untracked"
fi
# Format prompts.
zstyle -s ':git-info:' prompt prompt_format
zstyle -s ':git-info:' rprompt rprompt_format
zstyle -s ':omz:plugin:git:prompt' prompt prompt_format
zstyle -s ':omz:plugin:git:prompt' rprompt rprompt_format
git_info_vars=(
git_prompt_info "$prompt_format"