Skip to content

Commit

Permalink
Add _lp_time() and _lp_time_color()
Browse files Browse the repository at this point in the history
Both return a static result, based on $_LP_TIME_SYMBOL. But they check
$LP_ENABLE_TIME, which inlines some logic.

Fix _lp_analog_time() not checking $LP_TIME_ANALOG.

_lp_time() checks $LP_TIME_ANALOG, and returns 2 if it is set.
  • Loading branch information
Rycieos committed Nov 25, 2020
1 parent 862dcfb commit bc120d5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions liquidprompt
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,8 @@ lp_title() {
_LP_CLOCK=(🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧 )

_lp_analog_time() {
(( LP_ENABLE_TIME && LP_TIME_ANALOG )) || return 2

# %I: "00".."12" %M: "00".."59"
# hh: 1..12 mm: 0..59
local hh mm
Expand All @@ -2389,12 +2391,23 @@ _lp_analog_time() {
}

_lp_analog_time_color() {
(( LP_ENABLE_TIME && LP_TIME_ANALOG )) || return 2
_lp_analog_time || return "$?"

_lp_analog_time
lp_analog_time_color="${LP_COLOR_TIME}${lp_analog_time}${NO_COL}"
}

_lp_time() {
(( LP_ENABLE_TIME && ! LP_TIME_ANALOG )) || return 2

lp_time=${_LP_TIME_SYMBOL}
}

_lp_time_color() {
_lp_time || return "$?"

lp_time_color="${LP_COLOR_TIME}${_LP_TIME_SYMBOL}${NO_COL}"
}

#################
# Default theme #
#################
Expand Down Expand Up @@ -2446,10 +2459,8 @@ _lp_default_theme_activate() {
# during the shell's life
LP_TTYN="$(basename -- "$(tty)" 2>/dev/null)"

if (( LP_ENABLE_TIME )); then
if (( ! LP_TIME_ANALOG )); then
LP_TIME="${LP_COLOR_TIME}${_LP_TIME_SYMBOL}${NO_COL} "
fi
if _lp_time_color; then
LP_TIME="${lp_time_color} "
else
LP_TIME=
fi
Expand Down

0 comments on commit bc120d5

Please sign in to comment.