Move vcs to partial

This commit is contained in:
Paweł Płazieński 2024-03-03 12:54:14 +01:00
parent dc53d35fcc
commit b7f27f99e5
2 changed files with 56 additions and 55 deletions

56
zsh.d/50_vcs.zsh Normal file
View File

@ -0,0 +1,56 @@
# vim: ft=zsh
if [[ -n $MULTIBYTE_SUPPORTED ]]; then
UNSTAGED_CHARACTER="\ue168"
CHANGES_CHARACTER="\ue16b"
UNTRACKED_CHARACTER="\ue16c"
BRANCH_CHARACTER="\ue822"
REVISION_CHARACTER="\ue821"
AHEAD_CHARACTER="\ue174 "
BEHIND_CHARACTER="\ue175 "
ACTIONS_CHARACTER="\ue831"
else
UNSTAGED_CHARACTER="!"
CHANGES_CHARACTER="*"
UNTRACKED_CHARACTER="?"
BRANCH_CHARACTER="~"
REVISION_CHARACTER="r"
AHEAD_CHARACTER="+"
BEHIND_CHARACTER="-"
ACTIONS_CHARACTER="!"
fi
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
# these formats are set for PROMPT
zstyle ':vcs_info:*' formats "%s $BRANCH_CHARACTER%b $REVISION_CHARACTER%i%u"
zstyle ':vcs_info:*' actionformats "%s $BRANCH_CHARACTER%b $REVISION_CHARACTER%i%u [%a]"
zstyle ':vcs_info:*' branchformat '%b'
zstyle ':vcs_info:hg*' unstagedstr "$CHANGES_CHARACTER"
zstyle ':vcs_info:hg*' hgrevformat "%r" # default "%r:%h"
zstyle ':vcs_info:git*' formats "$BRANCH_CHARACTER%b%u%c%m" # git is standard
zstyle ':vcs_info:git*' actionformats "$BRANCH_CHARACTER%b%u%c%m $ACTIONS_CHARACTER%a"
zstyle ':vcs_info:git*' unstagedstr " $UNSTAGED_CHARACTER"
zstyle ':vcs_info:git*' stagedstr " $CHANGES_CHARACTER"
zstyle ':vcs_info:git*+set-message:*' hooks git-additional
function +vi-git-additional() {
local ahead behind
local -a branchstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(($ahead)) && branchstatus+=(" $AHEAD_CHARACTER${ahead}")
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(($behind)) && branchstatus+=(" $BEHIND_CHARACTER${behind}")
hook_com[misc]="${(j::)branchstatus}"
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' &&
-n $(git status --porcelain | grep -E '^\?\?' 2>/dev/null | tail -n1) ]]; then
hook_com[unstaged]+=" $UNTRACKED_CHARACTER"
fi
}

55
zshrc
View File

@ -20,37 +20,19 @@ if [[ -n $(echo '\u2603' 2>/dev/null) ]]; then
fi
if [[ -n $MULTIBYTE_SUPPORTED ]]; then
UNSTAGED_CHARACTER="\ue168"
CHANGES_CHARACTER="\ue16b"
UNTRACKED_CHARACTER="\ue16c"
BRANCH_CHARACTER="\ue822"
DETACHED_CHARACTER="\ue899"
REVISION_CHARACTER="\ue821"
FAILED_CHARACTER="\ue125"
SUCCESS_CHARACTER="\ue124"
SUPERUSER_CHARACTER="\ue22b"
JOBS_CHARACTER="\ue12a"
NO_JOBS_CHARACTER="\u2022"
AHEAD_CHARACTER="\ue174 "
BEHIND_CHARACTER="\ue175 "
ACTIONS_CHARACTER="\ue831"
SEGMENT_SEPARATOR_FORWARD="\ue0b0"
SEGMENT_SEPARATOR_BACKWARD="\ue0b2"
else
UNSTAGED_CHARACTER="!"
CHANGES_CHARACTER="*"
UNTRACKED_CHARACTER="?"
BRANCH_CHARACTER="~"
DETACHED_CHARACTER="%"
REVISION_CHARACTER="r"
FAILED_CHARACTER="X"
SUCCESS_CHARACTER="V"
SUPERUSER_CHARACTER="#"
JOBS_CHARACTER="O"
NO_JOBS_CHARACTER="."
AHEAD_CHARACTER="+"
BEHIND_CHARACTER="-"
ACTIONS_CHARACTER="!"
SEGMENT_SEPARATOR_FORWARD=""
SEGMENT_SEPARATOR_BACKWARD=""
fi
@ -190,43 +172,6 @@ export HISTFILE=~/.zsh_history
export HISTSIZE=1000000
export SAVEHIST=1000000
#---------------------------------- VCS ---------------------------------------
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
# these formats are set for PROMPT
zstyle ':vcs_info:*' formats "%s $BRANCH_CHARACTER%b $REVISION_CHARACTER%i%u"
zstyle ':vcs_info:*' actionformats "%s $BRANCH_CHARACTER%b $REVISION_CHARACTER%i%u [%a]"
zstyle ':vcs_info:*' branchformat '%b'
zstyle ':vcs_info:hg*' unstagedstr "$CHANGES_CHARACTER"
zstyle ':vcs_info:hg*' hgrevformat "%r" # default "%r:%h"
zstyle ':vcs_info:git*' formats "$BRANCH_CHARACTER%b%u%c%m" # git is standard
zstyle ':vcs_info:git*' actionformats "$BRANCH_CHARACTER%b%u%c%m $ACTIONS_CHARACTER%a"
zstyle ':vcs_info:git*' unstagedstr " $UNSTAGED_CHARACTER"
zstyle ':vcs_info:git*' stagedstr " $CHANGES_CHARACTER"
zstyle ':vcs_info:git*+set-message:*' hooks git-additional
function +vi-git-additional() {
local ahead behind
local -a branchstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(($ahead)) && branchstatus+=(" $AHEAD_CHARACTER${ahead}")
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(($behind)) && branchstatus+=(" $BEHIND_CHARACTER${behind}")
hook_com[misc]="${(j::)branchstatus}"
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' &&
-n $(git status --porcelain | grep -E '^\?\?' 2>/dev/null | tail -n1) ]]; then
hook_com[unstaged]+=" $UNTRACKED_CHARACTER"
fi
}
#---------------------------------- Aliases ----------------------------------
# Use interactive sudo instead of su