_lp_time_analog: optimize and fix variable leaks
This commit is contained in:
parent
1d5e621b1b
commit
4148a3d9a2
26
liquidprompt
26
liquidprompt
@ -1354,10 +1354,10 @@ _lp_time_analog()
|
|||||||
{
|
{
|
||||||
# get the date as "hours(12) minutes" in a single call
|
# get the date as "hours(12) minutes" in a single call
|
||||||
# make a bash array with it
|
# make a bash array with it
|
||||||
d=( $(date "+%I %M") )
|
local d=( $(date "+%I %M") )
|
||||||
# separate hours and minutes
|
# separate hours and minutes
|
||||||
hour=${d[0]#0} # no leading 0
|
local -i hour=${d[0]#0} # no leading 0
|
||||||
min=${d[1]#0}
|
local -i min=${d[1]#0}
|
||||||
|
|
||||||
# The targeted unicode characters are the "CLOCK FACE" ones
|
# The targeted unicode characters are the "CLOCK FACE" ones
|
||||||
# They are located in the codepages between:
|
# They are located in the codepages between:
|
||||||
@ -1365,19 +1365,19 @@ _lp_time_analog()
|
|||||||
# U+1F55C (ONE-THIRTY) and U+1F567 (TWELVE-THIRTY), for the thirties
|
# U+1F55C (ONE-THIRTY) and U+1F567 (TWELVE-THIRTY), for the thirties
|
||||||
#
|
#
|
||||||
|
|
||||||
plain=(🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 )
|
local plain=(🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 )
|
||||||
half=(🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 )
|
local half=(🕜 🕝 🕞 🕟 🕠 🕡 🕢 🕣 🕤 🕥 🕦 🕧 )
|
||||||
|
|
||||||
# array index starts at 0
|
# array index starts at 0
|
||||||
hi=$((hour-1))
|
local -i hi=hour-1
|
||||||
|
|
||||||
# add a space for correct alignment
|
# add a space for correct alignment
|
||||||
if [[ $min -lt 15 ]] ; then
|
if (( min < 15 )) ; then
|
||||||
echo -n "${plain[$hi]} "
|
echo -n "${plain[hi]} "
|
||||||
elif [[ $min -lt 45 ]] ; then
|
elif (( min < 45 )) ; then
|
||||||
echo -n "${half[$hi]} "
|
echo -n "${half[hi]} "
|
||||||
else
|
else
|
||||||
echo -n "${plain[$((hi+1))]} "
|
echo -n "${plain[hi+1]} "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1387,7 +1387,9 @@ _lp_time()
|
|||||||
if [[ "$LP_TIME_ANALOG" != 1 ]]; then
|
if [[ "$LP_TIME_ANALOG" != 1 ]]; then
|
||||||
echo -ne "${LP_COLOR_TIME}${_LP_TIME_SYMBOL}${NO_COL}"
|
echo -ne "${LP_COLOR_TIME}${_LP_TIME_SYMBOL}${NO_COL}"
|
||||||
else
|
else
|
||||||
echo -ne "${LP_COLOR_TIME}$(_lp_time_analog)${NO_COL}"
|
echo -ne "${LP_COLOR_TIME}"
|
||||||
|
_lp_time_analog
|
||||||
|
echo -ne "${NO_COL}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user