rename and clean

This commit is contained in:
Johann Dreo 2024-12-16 09:48:06 +01:00
commit 699a1871cd

View file

@ -1,193 +0,0 @@
_lp_boxed_theme_activate() {
LP_MARK_DEV_OPEN=
LP_MARK_DEV_CLOSE=
LP_MARK_DEV_MID=
LP_MARK_MODULES_OPEN=
LP_MARK_MODULES_SEP=
LP_MARK_MODULES_CLOSE=
LP_MARK_ENV_VARS_OPEN=
LP_MARK_ENV_VARS_SEP=
LP_MARK_ENV_VARS_CLOSE=
# BOXED_MULTIPLEXER=
# if _lp_multiplexer ; then
# BOXED_MULTIPLEXER="$lp_multiplexer"
# fi
_lp_default_theme_activate
}
_lp_boxed_theme_directory() {
_lp_default_theme_directory
}
_lp_boxed_theme_prompt() {
_lp_default_theme_prompt_data
_lp_boxed_theme_prompt_template
}
_box() {
local name="$1"
name_len=${#name}
# printf "$name\n"
if _lp_create_link "https://liquidprompt.readthedocs.io/en/stable/theme/default.html#LP_${name}" "${name,,}" ; then
name_link="$lp_link"
else
name_link="${name,,}"
fi
local what="$2"
__lp_strip_escapes "$what"
local raw_data="$ret"
local raw_data_len=${#raw_data}
local color="$3"
if [[ -n "$what" ]]; then
local i
box_top+="┬"
box_mid+="${color}│${NO_COL}$what"
box_bot+="┴"
__lp_strip_escapes "$box_mid"
local raw_mid="$ret"
# Fill in missing spaces, using box_mid as reference.
__lp_strip_escapes "$box_hyp"
local raw_hyp="$ret"
for (( i=${#raw_hyp}; i < ${#raw_mid}-raw_data_len; i++ )) ; do
box_hyp+=" "
done
# printf "${#box_sup} -> ${#raw_mid}\n"
__lp_strip_escapes "$box_sup"
local raw_sup="$ret"
for (( i=${#raw_sup}; i < ${#raw_mid}-raw_data_len; i++ )) ; do
box_sup+=" "
done
__lp_strip_escapes "$box_top"
local raw_top="$ret"
# Add names.
if (( name_len > raw_data_len )); then
# printf "On sup/hyp line\n"
local top_len=${#raw_top}
local cursor="${raw_sup:top_len:1}"
# printf "$raw_top\n"
# printf "${top_len}«${cursor}»\n"
if [[ "$cursor" != " " && "$cursor" != "" ]] ; then
# printf "On hyp line\n"
box_hyp+="┌$name_link"
box_top+="┴"
else
# printf "On sup line\n"
box_sup+="┌$name_link"
box_top+="┴"
fi
else
# printf "On top line\n"
box_top+="$name_link"
fi
# Fill in missing spaces, using box_mid as reference.
__lp_strip_escapes "$box_top"
local raw_top="$ret"
for (( i=${#raw_top}; i < ${#raw_mid}; i++ )) ; do
box_top+="─"
done
__lp_strip_escapes "$box_bot"
local raw_bot="$ret"
for (( i=${#raw_bot}; i < ${#raw_mid}; i++ )) ; do
box_bot+="─"
done
fi
# __lp_strip_escapes "$box_hyp"
# printf "$ret\n"
# __lp_strip_escapes "$box_sup"
# printf "$ret\n"
# __lp_strip_escapes "$box_top"
# printf "$ret\n"
# __lp_strip_escapes "$box_mid"
# printf "$ret\n"
# __lp_strip_escapes "$box_bot"
# printf "$ret\n"
}
_lp_boxed_theme_prompt_template() {
if [[ -f "${LP_PS1_FILE-}" ]]; then
# shellcheck source=liquid.ps1
source "$LP_PS1_FILE"
fi
if [[ -z "${LP_PS1-}" ]]; then
box_hyp=""
box_sup=""
box_top=""
box_mid=""
box_bot=""
lp_terminal_format 243
boxed_color="$lp_terminal_format"
# Add title escape time, battery, load, temperature, RAM, disk, wifi, jobs.
_box "PS1_PREFIX" "${LP_PS1_PREFIX}" "$boxed_color"
_box "TIME" "${LP_TIME}" "$boxed_color"
_box "BATT" "${LP_BATT}" "$boxed_color"
_box "LOAD" "${LP_LOAD}" "$boxed_color"
_box "TEMP" "${LP_TEMP}" "$boxed_color"
_box "RAM" "${LP_RAM}" "$boxed_color"
_box "DISK" "${LP_DISK}" "$boxed_color"
_box "WIFI" "${LP_WIFI}" "$boxed_color"
_box "JOBS" "${LP_JOBS}" "$boxed_color"
# Add multiplexer brackets, user, host, permissions colon, working directory, dirstack, proxy, watched environment variables and nested shell level.
# _box "MULTIPLEXER" "${BOXED_MULTIPLEXER}" "$boxed_color"
_box "BRACKET_OPEN" "${LP_BRACKET_OPEN}" "$boxed_color"
_box "USER" "${LP_USER}" "$boxed_color"
_box "HOST" "${LP_HOST}" "$boxed_color"
_box "PERM" "${LP_PERM}" "$boxed_color"
_box "PWD" "${LP_PWD}" "$boxed_color"
_box "DIRSTACK" "${LP_DIRSTACK}" "$boxed_color"
_box "BRACKET_CLOSE" "${LP_BRACKET_CLOSE}" "$boxed_color"
_box "PROXY" "${LP_PROXY}" "$boxed_color"
_box "ENVVARS" "${LP_ENVVARS}" "$boxed_color"
_box "SHLVL" "${LP_SHLVL}" "$boxed_color"
# Add the list of development environments/config/etc.
_box "DEV_ENV" "${LP_DEV_ENV}" "$boxed_color"
# Add VCS infos
# If root, the info has not been collected unless LP_ENABLE_VCS_ROOT
# is set.
_box "VCS" "${LP_VCS}" "$boxed_color"
# Add last runtime, return code & meaning, prompt mark and user-defined postfix.
_box "RUNTIME" "${LP_RUNTIME}" "$boxed_color"
_box "ERR" "${LP_ERR}" "$boxed_color"
_box "ERR_MEANING" "${LP_ERR_MEANING}" "$boxed_color"
box_hyp+=" "
box_sup+=" "
box_top+="┐"
box_mid+="${boxed_color}│${NO_COL}"
box_bot+="┘"
PS1="${boxed_color}"
if [[ -n ${box_hyp// } ]] ; then # If not just spaces.
PS1+="${box_hyp}\n"
fi
if [[ -n ${box_sup// } ]] ; then
PS1+="${box_sup}\n"
fi
PS1+="${box_top}${NO_COL}\n${box_mid}\n${boxed_color}${box_bot}${NO_COL}\n${LP_MARK_PREFIX}${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}"
else
PS1=$LP_PS1
fi
}