add the flowchart

This commit is contained in:
Johann Dreo 2023-07-09 12:20:42 +02:00
commit 2d090fe9be

View file

@ -70,8 +70,8 @@ _gitcrux_arrow() {
}
_gitcrux_VCS() {
GITCRUX_COL_WIDTH=11
GITCRUX_VCS="${n}"
GITCRUX_COL_WIDTH=0
GITCRUX_VCS=""
local head_remote head_repo head_stage head_branch
@ -152,10 +152,21 @@ _gitcrux_VCS() {
fi
# ARROWS
if [[ "$GITCRUX_COL_WIDTH" -eq "0" ]]; then
for col in "${head_remote}" "${head_repo}" "${head_stage}" "${head_branch}" "${head_stash}"; do
if (( ${#col} > GITCRUX_COL_WIDTH )); then
__lp_strip_escapes "${col}"
GITCRUX_COL_WIDTH="${#ret}"
fi
done
fi
# At least some spacing.
GITCRUX_COL_WIDTH=$((GITCRUX_COL_WIDTH+1))
header=""
line=""
for col in "${head_remote}" "${head_repo}" "${head_stage}" "${head_branch}" "${head_stash}"; do
_gitcrux_centered "│" $GITCRUX_COL_WIDTH
line+="$gitcrux_centered"
@ -163,32 +174,105 @@ _gitcrux_VCS() {
header+="$gitcrux_centered"
done
GITCRUX_VCS+="${header}${n}"
GITCRUX_VCS+="${line}${n}"
# GITCRUX_VCS+="${line}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 220 1" 1 4 "pull"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
# Available states:
# - $lp_vcs_commit_behind
# - $lp_vcs_commit_ahead
# - $has_lines:
# - $lp_vcs_unstaged_i_lines
# - $lp_vcs_unstaged_d_lines
# OR (depending on VCS)
# - $lp_vcs_uncommitted_i_lines
# - $lp_vcs_uncommitted_d_lines
# - $lp_vcs_head_status
# - $lp_vcs_head_details
# - $lp_vcs_untracked_files
# - $lp_vcs_stash_count
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 45 1" 2 4 "branch"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
if [[ "$lp_vcs_type" != "git" ]]; then
GITCRUX_VCS+="[Unsupported VCS, cannot provide hints.]${n}"
else # VCS is git
if [[ "$lp_vcs_head_status" ]]; then
if [[ "$lp_vcs_head_status" == *"REBASE"* ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 46 1" 3 4 "add"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # Unknown head status.
GITCRUX_VCS+="[Unsupported head status, cannot provide hints.]${n}"
fi
else # No specific head status.
if [[ "$lp_vcs_commit_behind" ]]; then
if [[ "$has_lines" ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 183 1" 4 5 "save"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 183 1" 4 5 "save"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 220 1" 1 4 "pull"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 46 1" 3 4 "add"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 183 1" 4 5 "pop"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # Do not have diff.
if [[ "$lp_vcs_stash_count" ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 220 1" 1 4 "pull"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 202 1" 2 3 "commit"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 183 1" 4 5 "pop"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # No stash.
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 220 1" 1 4 "pull"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
fi
fi
else # No commit behind.
if [[ "$has_lines" ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 46 1" 3 4 "add"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 183 1" 4 5 "pop"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 202 1" 2 3 "commit"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # Do not have diff.
if [[ "$lp_vcs_stash_count" ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 183 1" 4 5 "pop"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # Do not have stash.
if [[ "$lp_vcs_commit_ahead" ]]; then
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 220 1" 1 2 "push"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
else # No commit ahead.
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 45 1" 2 4 "branch"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
fi
fi
fi
fi
fi
fi
_gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 208 1" 2 4 "merge master"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 220 1" 1 4 "pull"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
_gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 220 1" 1 2 "push"
GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 45 1" 2 4 "branch"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 183 1" 4 5 "save"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 46 1" 3 4 "add"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 202 1" 2 3 "commit"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 183 1" 4 5 "pop"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_RIGHT[@]} "0 208 1" 2 4 "merge master"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
# _gitcrux_arrow "$line" ${GITCRUX_ARROW_LEFT[@]} "0 220 1" 1 2 "push"
# GITCRUX_VCS+="${gitcrux_arrow}${n}"
}
@ -234,7 +318,7 @@ _lp_gitcrux_theme_prompt() {
fi
# prompt mark and user-defined postfix
PS1+="${n}${LP_MARK_PREFIX}${LP_COLOR_MARK}${LP_MARK}${LP_PS1_POSTFIX}"
PS1+="${LP_MARK_PREFIX}${LP_COLOR_MARK}${LP_MARK}${LP_PS1_POSTFIX}"
# Get the core sections without prompt escapes and make them into a title.
_lp_formatted_title "${LP_PS1_PREFIX}${LP_BRACKET_OPEN}${LP_USER}${LP_HOST}${LP_MARK_PERM}${lp_path-}${LP_BRACKET_CLOSE}${LP_MARK_PREFIX}${LP_MARK}${LP_PS1_POSTFIX}"