fix: working under Zsh

This commit is contained in:
Johann Dreo 2022-11-02 15:31:45 +01:00
commit 4f9312af01
2 changed files with 21 additions and 20 deletions

View file

@ -14,7 +14,7 @@ Has such, you may find it a little bit disconcerting at first.
But we believe that the advantages of this design makes it worth the effort. But we believe that the advantages of this design makes it worth the effort.
NOTE: as of now, DotMatrix only work for Bash (> 3.2), but not for Zsh. That will hopefully change in the future. NOTE: as of now, DotMatrix may be a little bugged on Zsh.
Preview Preview

View file

@ -282,7 +282,7 @@ _lp_dotmatrix_theme_directory() {
_lp_dotmatrix_theme_prompt() { _lp_dotmatrix_theme_prompt() {
local header inline prompt local header inline dotmatrix_prompt
# Arguments: fg, bg, bold, underline, fallback_fg, fallback_bg # Arguments: fg, bg, bold, underline, fallback_fg, fallback_bg
# Color codes can be any integer in 256 XTerm's system colors in [0255]. # Color codes can be any integer in 256 XTerm's system colors in [0255].
@ -296,6 +296,7 @@ _lp_dotmatrix_theme_prompt() {
# HEADER (LEFT) # HEADER (LEFT)
#################################################################### ####################################################################
# PS1="headering> "
header="" header=""
header+="${_DOTMATRIX_DISPLAY}" header+="${_DOTMATRIX_DISPLAY}"
header+="${_DOTMATRIX_CONNECTION}" header+="${_DOTMATRIX_CONNECTION}"
@ -549,7 +550,7 @@ _lp_dotmatrix_theme_prompt() {
inline_right+="${DOTMATRIX_LINE}" inline_right+="${DOTMATRIX_LINE}"
local inline local inline=
# FIXME use _lp_fill-like function to handle multi-character line? # FIXME use _lp_fill-like function to handle multi-character line?
if ((DOTMATRIX_ENABLE_GRADIENT_LINE)); then if ((DOTMATRIX_ENABLE_GRADIENT_LINE)); then
# Fill up the center section with a line colored as a gradient. # Fill up the center section with a line colored as a gradient.
@ -587,35 +588,35 @@ _lp_dotmatrix_theme_prompt() {
# PROMPT LINE # PROMPT LINE
#################################################################### ####################################################################
prompt="" dotmatrix_prompt=""
lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"} lp_terminal_format ${DOTMATRIX_COLOR_DARK[@]+"${DOTMATRIX_COLOR_DARK[@]}"}
if (( LP_ENABLE_WIFI_STRENGTH )) ; then if (( LP_ENABLE_WIFI_STRENGTH )) ; then
if _lp_wifi_signal_strength ; then if _lp_wifi_signal_strength ; then
lp_terminal_format ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} lp_terminal_format ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}
prompt+="${lp_terminal_format}${LP_MARK_WIFI}" dotmatrix_prompt+="${lp_terminal_format}${LP_MARK_WIFI}"
else else
prompt+="${lp_terminal_format}${LP_MARK_WIFI}" dotmatrix_prompt+="${lp_terminal_format}${LP_MARK_WIFI}"
fi fi
else else
prompt+="${lp_terminal_format}·" dotmatrix_prompt+="${lp_terminal_format}·"
fi fi
if _lp_http_proxy ; then if _lp_http_proxy ; then
__dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"}
prompt+="${dotmatrix_sep}" dotmatrix_prompt+="${dotmatrix_sep}"
else else
__dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"} __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_LITE[@]+"${DOTMATRIX_COLOR_LITE[@]}"}
prompt+="${dotmatrix_sep}" dotmatrix_prompt+="${dotmatrix_sep}"
fi fi
__dotmatrix_prompt_vcs __dotmatrix_prompt_vcs
prompt+="${_DOTMATRIX_VCS}" dotmatrix_prompt+="${_DOTMATRIX_VCS}"
if _lp_runtime_format ; then if _lp_runtime_format ; then
__dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}
__dotmatrix_make_field "${lp_runtime_format}" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"} __dotmatrix_make_field "${lp_runtime_format}" ${DOTMATRIX_COLOR_NOTE[@]+"${DOTMATRIX_COLOR_NOTE[@]}"}
prompt+="${dotmatrix_sep}${dotmatrix_field}" dotmatrix_prompt+="${dotmatrix_sep}${dotmatrix_field}"
fi fi
if _lp_error ; then if _lp_error ; then
@ -627,11 +628,11 @@ _lp_dotmatrix_theme_prompt() {
fi fi
__dotmatrix_make_sep_link ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} __dotmatrix_make_sep_link ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}
__dotmatrix_make_field "${DOTMATRIX_MARK_ERROR}${DOTMATRIX_SPACE_VOID}${error_msg}" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"} __dotmatrix_make_field "${DOTMATRIX_MARK_ERROR}${DOTMATRIX_SPACE_VOID}${error_msg}" ${DOTMATRIX_COLOR_WARN[@]+"${DOTMATRIX_COLOR_WARN[@]}"}
prompt+="${dotmatrix_sep}${dotmatrix_field}" dotmatrix_prompt+="${dotmatrix_sep}${dotmatrix_field}"
fi fi
__dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"} __dotmatrix_make_sep_plug ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"}
prompt+="${dotmatrix_sep}" dotmatrix_prompt+="${dotmatrix_sep}"
lp_terminal_format ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"} lp_terminal_format ${DOTMATRIX_COLOR_MARK[@]+"${DOTMATRIX_COLOR_MARK[@]}"}
local mark_color="$lp_terminal_format" local mark_color="$lp_terminal_format"
@ -639,11 +640,11 @@ _lp_dotmatrix_theme_prompt() {
if _lp_shell_level ; then if _lp_shell_level ; then
local i local i
for ((i=0; i < lp_shell_level-1; i++)); do for ((i=0; i < lp_shell_level-1; i++)); do
prompt+="${mark_color}${DOTMATRIX_MARK}" dotmatrix_prompt+="${mark_color}${DOTMATRIX_MARK}"
done done
fi fi
# Warning prompt mark if either root or sudo. # Warning dotmatrix_prompt mark if either root or sudo.
_lp_user _lp_user
user="$?" user="$?"
# No need to check LP_ENABLE_SUDO, _lp_sudo_active does it. # No need to check LP_ENABLE_SUDO, _lp_sudo_active does it.
@ -653,16 +654,16 @@ _lp_dotmatrix_theme_prompt() {
local dcwfg="${DOTMATRIX_COLOR_WARN[_LP_FIRST_INDEX+1]}" local dcwfg="${DOTMATRIX_COLOR_WARN[_LP_FIRST_INDEX+1]}"
[[ -z $dcwfg ]] && dcwfg=-1 [[ -z $dcwfg ]] && dcwfg=-1
lp_terminal_format $dcwfg lp_terminal_format $dcwfg
prompt+="${lp_terminal_format}${DOTMATRIX_MARK}" dotmatrix_prompt+="${lp_terminal_format}${DOTMATRIX_MARK}"
else else
prompt+="${mark_color}${DOTMATRIX_MARK}" dotmatrix_prompt+="${mark_color}${DOTMATRIX_MARK}"
fi fi
prompt+="${NO_COL}" dotmatrix_prompt+="${NO_COL}"
# Assemble and setup # Assemble and setup
local n=$'\n' local n=$'\n'
PS1="${n}${header}${n}${inline}${n}${prompt} " PS1="${n}${header}${n}${inline}${n}${dotmatrix_prompt} "
} }
@ -875,7 +876,7 @@ __dotmatrix_directory_path() {
######################################################################## ########################################################################
# Functions called at prompt update. # Functions called at dotmatrix_prompt update.
######################################################################## ########################################################################
__dotmatrix_prompt_vcs() { __dotmatrix_prompt_vcs() {