feat: add links

This commit is contained in:
Johann Dreo 2024-12-15 21:53:04 +01:00
commit 8d84d3bb67

View file

@ -31,6 +31,11 @@ _box() {
local name="$1" local name="$1"
name_len=${#name} name_len=${#name}
# printf "$name\n" # 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" local what="$2"
__lp_strip_escapes "$what" __lp_strip_escapes "$what"
@ -45,43 +50,55 @@ _box() {
box_mid+="${color}│${NO_COL}$what" box_mid+="${color}│${NO_COL}$what"
box_bot+="┴" box_bot+="┴"
# Fill in missing spaces, using box_mid as reference.
__lp_strip_escapes "$box_mid" __lp_strip_escapes "$box_mid"
local mid="$ret" local raw_mid="$ret"
for (( i=${#box_hyp}; i < ${#mid}-raw_data_len; i++ )) ; do
# 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+=" " box_hyp+=" "
done done
# printf "${#box_sup} -> ${#mid}\n" # printf "${#box_sup} -> ${#raw_mid}\n"
for (( i=${#box_sup}; i < ${#mid}-raw_data_len; i++ )) ; do __lp_strip_escapes "$box_sup"
local raw_sup="$ret"
for (( i=${#raw_sup}; i < ${#raw_mid}-raw_data_len; i++ )) ; do
box_sup+=" " box_sup+=" "
done done
__lp_strip_escapes "$box_top"
local raw_top="$ret"
# Add names. # Add names.
if (( name_len > raw_data_len )); then if (( name_len > raw_data_len )); then
# printf "On sup/hyp line\n" # printf "On sup/hyp line\n"
local btlen=${#box_top} local top_len=${#raw_top}
local cursor="${box_sup:btlen:1}" local cursor="${raw_sup:top_len:1}"
# printf "${btlen}«${cursor}»\n" # printf "$raw_top\n"
# printf "${top_len}«${cursor}»\n"
if [[ "$cursor" != " " && "$cursor" != "" ]] ; then if [[ "$cursor" != " " && "$cursor" != "" ]] ; then
# printf "On hyp line\n" # printf "On hyp line\n"
box_hyp+="┌$name" box_hyp+="┌$name_link"
box_top+="┴" box_top+="┴"
else else
# printf "On sup line\n" # printf "On sup line\n"
box_sup+="┌$name" box_sup+="┌$name_link"
box_top+="┴" box_top+="┴"
fi fi
else else
# printf "On top line\n" # printf "On top line\n"
box_top+="$name" box_top+="$name_link"
fi fi
# Fill in missing spaces, using box_mid as reference. # Fill in missing spaces, using box_mid as reference.
for (( i=${#box_top}; i < ${#mid}; i++ )) ; do __lp_strip_escapes "$box_top"
local raw_top="$ret"
for (( i=${#raw_top}; i < ${#raw_mid}; i++ )) ; do
box_top+="─" box_top+="─"
done done
for (( i=${#box_bot}; i < ${#mid}; i++ )) ; do __lp_strip_escapes "$box_bot"
local raw_bot="$ret"
for (( i=${#raw_bot}; i < ${#raw_mid}; i++ )) ; do
box_bot+="─" box_bot+="─"
done done
@ -117,40 +134,40 @@ _lp_boxed_theme_prompt_template() {
boxed_color="$lp_terminal_format" boxed_color="$lp_terminal_format"
# Add title escape time, battery, load, temperature, RAM, disk, wifi, jobs. # Add title escape time, battery, load, temperature, RAM, disk, wifi, jobs.
_box "ps1_prefix" "${LP_PS1_PREFIX}" "$boxed_color" _box "PS1_PREFIX" "${LP_PS1_PREFIX}" "$boxed_color"
_box "time" "${LP_TIME}" "$boxed_color" _box "TIME" "${LP_TIME}" "$boxed_color"
_box "batt" "${LP_BATT}" "$boxed_color" _box "BATT" "${LP_BATT}" "$boxed_color"
_box "load" "${LP_LOAD}" "$boxed_color" _box "LOAD" "${LP_LOAD}" "$boxed_color"
_box "temp" "${LP_TEMP}" "$boxed_color" _box "TEMP" "${LP_TEMP}" "$boxed_color"
_box "ram" "${LP_RAM}" "$boxed_color" _box "RAM" "${LP_RAM}" "$boxed_color"
_box "disk" "${LP_DISK}" "$boxed_color" _box "DISK" "${LP_DISK}" "$boxed_color"
_box "wifi" "${LP_WIFI}" "$boxed_color" _box "WIFI" "${LP_WIFI}" "$boxed_color"
_box "jobs" "${LP_JOBS}" "$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. # 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 "MULTIPLEXER" "${BOXED_MULTIPLEXER}" "$boxed_color"
_box "bracket_open" "${LP_BRACKET_OPEN}" "$boxed_color" _box "BRACKET_OPEN" "${LP_BRACKET_OPEN}" "$boxed_color"
_box "user" "${LP_USER}" "$boxed_color" _box "USER" "${LP_USER}" "$boxed_color"
_box "host" "${LP_HOST}" "$boxed_color" _box "HOST" "${LP_HOST}" "$boxed_color"
_box "perm" "${LP_PERM}" "$boxed_color" _box "PERM" "${LP_PERM}" "$boxed_color"
_box "pwd" "${LP_PWD}" "$boxed_color" _box "PWD" "${LP_PWD}" "$boxed_color"
_box "dirstack" "${LP_DIRSTACK}" "$boxed_color" _box "DIRSTACK" "${LP_DIRSTACK}" "$boxed_color"
_box "bracket_close" "${LP_BRACKET_CLOSE}" "$boxed_color" _box "BRACKET_CLOSE" "${LP_BRACKET_CLOSE}" "$boxed_color"
_box "proxy" "${LP_PROXY}" "$boxed_color" _box "PROXY" "${LP_PROXY}" "$boxed_color"
_box "envvars" "${LP_ENVVARS}" "$boxed_color" _box "ENVVARS" "${LP_ENVVARS}" "$boxed_color"
_box "shlvl" "${LP_SHLVL}" "$boxed_color" _box "SHLVL" "${LP_SHLVL}" "$boxed_color"
# Add the list of development environments/config/etc. # Add the list of development environments/config/etc.
_box "dev_env" "${LP_DEV_ENV}" "$boxed_color" _box "DEV_ENV" "${LP_DEV_ENV}" "$boxed_color"
# Add VCS infos # Add VCS infos
# If root, the info has not been collected unless LP_ENABLE_VCS_ROOT # If root, the info has not been collected unless LP_ENABLE_VCS_ROOT
# is set. # is set.
_box "vcs" "${LP_VCS}" "$boxed_color" _box "VCS" "${LP_VCS}" "$boxed_color"
# Add last runtime, return code & meaning, prompt mark and user-defined postfix. # Add last runtime, return code & meaning, prompt mark and user-defined postfix.
_box "runtime" "${LP_RUNTIME}" "$boxed_color" _box "RUNTIME" "${LP_RUNTIME}" "$boxed_color"
_box "err" "${LP_ERR}" "$boxed_color" _box "ERR" "${LP_ERR}" "$boxed_color"
_box "err_meaning" "${LP_ERR_MEANING}" "$boxed_color" _box "ERR_MEANING" "${LP_ERR_MEANING}" "$boxed_color"
box_hyp+=" " box_hyp+=" "
box_sup+=" " box_sup+=" "