feat(config): add several configuration variables and refactor colors
- fixes color of explanation in Zsh - adds GITCRUX_MARK_EXPLANATION - adds GITCRUX_ENABLE_EXPLANATION_NEWLINE - adds GITCRUX_VCS_MARK - adds GITCRUX_VCS_FILL - adds GITCRUX_COLOR_FILL
This commit is contained in:
parent
867d76cafc
commit
e2d875b3ce
1 changed files with 45 additions and 16 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
|
|
||||||
# Center the given $1 text with spaces to fit a string of length $2.
|
# Center the given $1 text with $3 to fit a string of length $2.
|
||||||
_gitcrux_centered() {
|
_gitcrux_centered() { # text length [fill_char=' ']
|
||||||
local text width padl padr span diff i
|
local text width padl padr span diff i
|
||||||
text="$1"
|
text="$1"
|
||||||
width="$2"
|
width="$2"
|
||||||
|
fill=${3:-" "}
|
||||||
|
|
||||||
__lp_strip_escapes "$text"
|
__lp_strip_escapes "$text"
|
||||||
raw_text="$ret"
|
raw_text="$ret"
|
||||||
|
|
@ -20,12 +21,12 @@ _gitcrux_centered() {
|
||||||
padl=""
|
padl=""
|
||||||
padr=""
|
padr=""
|
||||||
for (( i=0; i < diff; i++ )) ; do
|
for (( i=0; i < diff; i++ )) ; do
|
||||||
padl+=" "
|
padl+="$fill"
|
||||||
padr+=" "
|
padr+="$fill"
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( span % 2 > 0 )); then
|
if (( span % 2 > 0 )); then
|
||||||
padr+=" "
|
padr+="$fill"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gitcrux_centered="${padl}${text}${padr}"
|
gitcrux_centered="${padl}${text}${padr}"
|
||||||
|
|
@ -180,13 +181,16 @@ _gitcrux_VCS_header() {
|
||||||
GITCRUX_COL_WIDTH=$((GITCRUX_COL_WIDTH+2))
|
GITCRUX_COL_WIDTH=$((GITCRUX_COL_WIDTH+2))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gitcrux_VCS_header=""
|
local fill
|
||||||
|
gitcrux_VCS_header="$GITCRUX_VCS_MARK"
|
||||||
_GITCRUX_HEADER_LINE=""
|
_GITCRUX_HEADER_LINE=""
|
||||||
for col in "${head_remote}" "${head_repo}" "${head_stage}" "${head_branch}" "${head_stash}"; do
|
for col in "${head_remote}" "${head_repo}" "${head_stage}" "${head_branch}" "${head_stash}"; do
|
||||||
_gitcrux_centered "│" $GITCRUX_COL_WIDTH
|
_gitcrux_centered "│" $GITCRUX_COL_WIDTH
|
||||||
_GITCRUX_HEADER_LINE+="$gitcrux_centered"
|
_GITCRUX_HEADER_LINE+="$gitcrux_centered"
|
||||||
|
|
||||||
_gitcrux_centered "${col}" $GITCRUX_COL_WIDTH
|
lp_terminal_format ${GITCRUX_COLOR_FILL[@]+"${GITCRUX_COLOR_FILL[@]}"}
|
||||||
|
fill="${lp_terminal_format}${GITCRUX_VCS_FILL}${NO_COL}"
|
||||||
|
_gitcrux_centered "${col}" $GITCRUX_COL_WIDTH "$fill"
|
||||||
gitcrux_VCS_header+="$gitcrux_centered"
|
gitcrux_VCS_header+="$gitcrux_centered"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
@ -194,14 +198,17 @@ _gitcrux_VCS_header() {
|
||||||
_gitcrux_explain() {
|
_gitcrux_explain() {
|
||||||
local n=$'\n'
|
local n=$'\n'
|
||||||
if (( GITCRUX_SHOW_EXPLANATION )); then
|
if (( GITCRUX_SHOW_EXPLANATION )); then
|
||||||
lp_terminal_format ${GITCRUX_COLOR_EXPLANATION[@]}
|
if (( GITCRUX_ENABLE_EXPLANATION_NEWLINE )); then
|
||||||
GITCRUX_VCS+="${lp_terminal_format}${1}${NO_COL}"
|
GITCRUX_VCS+="${n}"
|
||||||
|
fi
|
||||||
|
lp_terminal_format ${GITCRUX_COLOR_EXPLANATION[@]+"${GITCRUX_COLOR_EXPLANATION[@]}"}
|
||||||
|
GITCRUX_VCS+="${lp_terminal_format}${GITCRUX_MARK_EXPLANATION}${1}${NO_COL}"
|
||||||
fi
|
fi
|
||||||
GITCRUX_VCS+="${n}"
|
GITCRUX_VCS+="${n}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_gitcrux_VCS() {
|
_gitcrux_VCS() {
|
||||||
local n=$'\n' explanation="#"
|
local n=$'\n' explanation=""
|
||||||
|
|
||||||
_gitcrux_VCS_header
|
_gitcrux_VCS_header
|
||||||
GITCRUX_VCS+="${gitcrux_VCS_header}${n}"
|
GITCRUX_VCS+="${gitcrux_VCS_header}${n}"
|
||||||
|
|
@ -440,19 +447,25 @@ _lp_gitcrux_theme_activate() {
|
||||||
GITCRUX_THRESH_STASH_STRONG=${GITCRUX_THRESH_STASH_STRONG:-5}
|
GITCRUX_THRESH_STASH_STRONG=${GITCRUX_THRESH_STASH_STRONG:-5}
|
||||||
|
|
||||||
# Light blue.
|
# Light blue.
|
||||||
GITCRUX_COLOR_WEAK=${GITCRUX_COLOR_WEAK:-"0 195 0"}
|
GITCRUX_COLOR_WEAK=( ${GITCRUX_COLOR_WEAK[@]+"${GITCRUX_COLOR_WEAK[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_WEAK[@]} == 0 ]] && GITCRUX_COLOR_WEAK=( 0 195 0 0 14 0 )
|
||||||
|
# fg, bg, bold, underline, fallback_fg, fallback_bg
|
||||||
|
|
||||||
# Blue bold.
|
# Blue bold.
|
||||||
GITCRUX_COLOR_NORMAL=${GITCRUX_COLOR_NORMAL:-"0 39 1"}
|
GITCRUX_COLOR_NORMAL=( ${GITCRUX_COLOR_NORMAL[@]+"${GITCRUX_COLOR_NORMAL[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_NORMAL[@]} == 0 ]] && GITCRUX_COLOR_NORMAL=( 0 39 1 0 0 12 )
|
||||||
|
|
||||||
# Red/pink bold.
|
# Red/pink bold.
|
||||||
GITCRUX_COLOR_STRONG=${GITCRUX_COLOR_STRONG:-"0 220 1"}
|
GITCRUX_COLOR_STRONG=( ${GITCRUX_COLOR_STRONG[@]+"${GITCRUX_COLOR_STRONG[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_STRONG[@]} == 0 ]] && GITCRUX_COLOR_STRONG=( 0 220 1 0 0 11 )
|
||||||
|
|
||||||
# Grey.
|
# Grey.
|
||||||
GITCRUX_COLOR_MSG=${GITCRUX_COLOR_MSG:-"0 244 0"}
|
GITCRUX_COLOR_MSG=( ${GITCRUX_COLOR_MSG[@]+"${GITCRUX_COLOR_MSG[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_MSG[@]} == 0 ]] && GITCRUX_COLOR_MSG=( 0 244 0 0 0 8 )
|
||||||
|
|
||||||
lp_terminal_format # Dark green.
|
# Dark green.
|
||||||
GITCRUX_COLOR_EXPLANATION=${GITCRUX_COLOR_EXPLANATION:-"28 -1 0"}
|
GITCRUX_COLOR_EXPLANATION=( ${GITCRUX_COLOR_EXPLANATION[@]+"${GITCRUX_COLOR_EXPLANATION[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_EXPLANATION[@]} == 0 ]] && GITCRUX_COLOR_EXPLANATION=( 28 0 0 0 2 0 )
|
||||||
|
|
||||||
# Width of a single column.
|
# Width of a single column.
|
||||||
local longest="< commit <"
|
local longest="< commit <"
|
||||||
|
|
@ -463,6 +476,22 @@ _lp_gitcrux_theme_activate() {
|
||||||
|
|
||||||
# Show a sentence explaining why the hint is shown.
|
# Show a sentence explaining why the hint is shown.
|
||||||
GITCRUX_SHOW_EXPLANATION=${GITCRUX_SHOW_EXPLANATION:-1}
|
GITCRUX_SHOW_EXPLANATION=${GITCRUX_SHOW_EXPLANATION:-1}
|
||||||
|
|
||||||
|
# Mark introducing the explanation (possibly with a new line).
|
||||||
|
GITCRUX_MARK_EXPLANATION=${GITCRUX_MARK_EXPLANATION:-"☝️ "}
|
||||||
|
|
||||||
|
# Put the explanation on a new line instead of after the last arrow line.
|
||||||
|
GITCRUX_ENABLE_EXPLANATION_NEWLINE=${GITCRUX_ENABLE_EXPLANATION_NEWLINE:-1}
|
||||||
|
|
||||||
|
# Mark for starting the VCS line.
|
||||||
|
GITCRUX_VCS_MARK=${GITCRUX_VCS_MARK:-""}
|
||||||
|
|
||||||
|
# Character used to fill in spaces between the VCS line items.
|
||||||
|
GITCRUX_VCS_FILL=${GITCRUX_VCS_FILL:-"·"}
|
||||||
|
|
||||||
|
# Color of the filling character.
|
||||||
|
GITCRUX_COLOR_FILL=( ${GITCRUX_COLOR_FILL[@]+"${GITCRUX_COLOR_FILL[@]}"} )
|
||||||
|
[[ ${#GITCRUX_COLOR_FILL[@]} == 0 ]] && GITCRUX_COLOR_FILL=( 240 0 0 0 8 0 )
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function is called everytime the user change their directory.
|
# This function is called everytime the user change their directory.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue