mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 20:41:44 +00:00
Use zstyle instead of variables for configuration.
This commit is contained in:
@ -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"
|
||||
|
@ -1,18 +1,53 @@
|
||||
# The default styles.
|
||||
zstyle ':git-info:' action 'action:%s' # %s - Special action name (am, merge, rebase).
|
||||
zstyle ':git-info:' added 'added:%a' # %a - Indicator to notify of added files.
|
||||
zstyle ':git-info:' ahead 'ahead:%A' # %A - Indicator to notify of ahead branch.
|
||||
zstyle ':git-info:' behind 'behind:%B' # %B - Indicator to notify of behind branch.
|
||||
zstyle ':git-info:' branch '%b' # %b - Branch name.
|
||||
zstyle ':git-info:' clean 'clean' # %C - Indicator to notify of clean branch.
|
||||
zstyle ':git-info:' commit 'commit:%c' # %c - SHA-1 hash.
|
||||
zstyle ':git-info:' deleted 'deleted:%d' # %d - Indicator to notify of deleted files.
|
||||
zstyle ':git-info:' dirty 'dirty' # %D - Indicator to notify of dirty branch.
|
||||
zstyle ':git-info:' modified 'modified:%m' # %m - Indicator to notify of modified files.
|
||||
zstyle ':git-info:' remote '%R' # %R - Remote name.
|
||||
zstyle ':git-info:' renamed 'renamed:%r' # %r - Indicator to notify of renamed files.
|
||||
zstyle ':git-info:' stashed 'stashed:%S' # %S - Indicator to notify of stashed files.
|
||||
zstyle ':git-info:' unmerged 'unmerged:%U' # %U - Indicator to notify of unmerged files.
|
||||
zstyle ':git-info:' untracked 'untracked:%u' # %u - Indicator to notify of untracked files.
|
||||
zstyle ':git-info:' prompt ' git:(%b %D%C)' # Left prompt.
|
||||
zstyle ':git-info:' rprompt '' # Right prompt.
|
||||
|
||||
# %s - Special action name (am, merge, rebase).
|
||||
zstyle ':omz:plugin:git:prompt' action 'action:%s'
|
||||
|
||||
# %a - Indicator to notify of added files.
|
||||
zstyle ':omz:plugin:git:prompt' added 'added:%a'
|
||||
|
||||
# %A - Indicator to notify of ahead branch.
|
||||
zstyle ':omz:plugin:git:prompt' ahead 'ahead:%A'
|
||||
|
||||
# %B - Indicator to notify of behind branch.
|
||||
zstyle ':omz:plugin:git:prompt' behind 'behind:%B'
|
||||
|
||||
# %b - Branch name.
|
||||
zstyle ':omz:plugin:git:prompt' branch '%b'
|
||||
|
||||
# %C - Indicator to notify of clean branch.
|
||||
zstyle ':omz:plugin:git:prompt' clean 'clean'
|
||||
|
||||
# %c - SHA-1 hash.
|
||||
zstyle ':omz:plugin:git:prompt' commit 'commit:%c'
|
||||
|
||||
# %d - Indicator to notify of deleted files.
|
||||
zstyle ':omz:plugin:git:prompt' deleted 'deleted:%d'
|
||||
|
||||
# %D - Indicator to notify of dirty branch.
|
||||
zstyle ':omz:plugin:git:prompt' dirty 'dirty'
|
||||
|
||||
# %m - Indicator to notify of modified files.
|
||||
zstyle ':omz:plugin:git:prompt' modified 'modified:%m'
|
||||
|
||||
# %R - Remote name.
|
||||
zstyle ':omz:plugin:git:prompt' remote '%R'
|
||||
|
||||
# %r - Indicator to notify of renamed files.
|
||||
zstyle ':omz:plugin:git:prompt' renamed 'renamed:%r'
|
||||
|
||||
# %S - Indicator to notify of stashed files.
|
||||
zstyle ':omz:plugin:git:prompt' stashed 'stashed:%S'
|
||||
|
||||
# %U - Indicator to notify of unmerged files.
|
||||
zstyle ':omz:plugin:git:prompt' unmerged 'unmerged:%U'
|
||||
|
||||
# %u - Indicator to notify of untracked files.
|
||||
zstyle ':omz:plugin:git:prompt' untracked 'untracked:%u'
|
||||
|
||||
# Left prompt.
|
||||
zstyle ':omz:plugin:git:prompt' prompt ' git:(%b %D%C)'
|
||||
|
||||
# Right prompt.
|
||||
zstyle ':omz:plugin:git:prompt' rprompt ''
|
||||
|
||||
|
Reference in New Issue
Block a user