1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 17:54:20 +00:00

fix: precision issue in battery metrics and adaptive purge UI

- cmd/status: use ParseUint to handle negative battery power values correctly
- bin/purge: make path truncation adaptive to terminal width
This commit is contained in:
Tw93
2026-01-14 11:55:24 +08:00
parent 9c996e944e
commit facaf5b34c
2 changed files with 26 additions and 7 deletions

View File

@@ -98,7 +98,14 @@ perform_purge() {
# Function to truncate path in the middle
truncate_path() {
local path="$1"
local max_len=80
local term_cols
term_cols=$(tput cols 2>/dev/null || echo 80)
# Reserve some space for the spinner and text (approx 20 chars)
local max_len=$((term_cols - 20))
# Ensure a reasonable minimum width
if (( max_len < 40 )); then
max_len=40
fi
if [[ ${#path} -le $max_len ]]; then
echo "$path"