diff --git a/bin/analyze-go b/bin/analyze-go index 07fc5d3..3fb42f8 100755 Binary files a/bin/analyze-go and b/bin/analyze-go differ diff --git a/cmd/analyze/view.go b/cmd/analyze/view.go index f5c9109..e2b50c8 100644 --- a/cmd/analyze/view.go +++ b/cmd/analyze/view.go @@ -323,18 +323,18 @@ func (m model) View() string { if m.inOverviewMode() { // Show ← Back if there's history (entered from a parent directory) if len(m.history) > 0 { - fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F Show | ← Back | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F File | ← Back | Q Quit%s\n", colorGray, colorReset) } else { - fmt.Fprintf(&b, "%s↑↓→ | Enter | R Refresh | O Open | F Show | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓→ | Enter | R Refresh | O Open | F File | Q Quit%s\n", colorGray, colorReset) } } else if m.showLargeFiles { - fmt.Fprintf(&b, "%s↑↓← | R Refresh | O Open | F Show | ⌫ Delete | ← Back | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓← | R Refresh | O Open | F File | ⌫ Del | ← Back | Q Quit%s\n", colorGray, colorReset) } else { largeFileCount := len(m.largeFiles) if largeFileCount > 0 { - fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F Show | ⌫ Delete | T Top(%d) | Q Quit%s\n", colorGray, largeFileCount, colorReset) + fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F File | ⌫ Del | T Top(%d) | Q Quit%s\n", colorGray, largeFileCount, colorReset) } else { - fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F Show | ⌫ Delete | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓←→ | Enter | R Refresh | O Open | F File | ⌫ Del | Q Quit%s\n", colorGray, colorReset) } } if m.deleteConfirm && m.deleteTarget != nil { diff --git a/lib/core/ui.sh b/lib/core/ui.sh index 4532854..72332f1 100755 --- a/lib/core/ui.sh +++ b/lib/core/ui.sh @@ -172,3 +172,43 @@ mo_spinner_chars() { [[ -z "$chars" ]] && chars="|/-\\" printf "%s" "$chars" } + +# Format last used time for display +# Args: $1 = last used string (e.g., "3 days ago", "Today", "Never") +# Returns: Compact version (e.g., "3d ago", "Today", "Never") +format_last_used_summary() { + local value="$1" + + case "$value" in + "" | "Unknown") + echo "Unknown" + return 0 + ;; + "Never" | "Recent" | "Today" | "Yesterday" | "This year" | "Old") + echo "$value" + return 0 + ;; + esac + + if [[ $value =~ ^([0-9]+)[[:space:]]+days?\ ago$ ]]; then + echo "${BASH_REMATCH[1]}d ago" + return 0 + fi + if [[ $value =~ ^([0-9]+)[[:space:]]+weeks?\ ago$ ]]; then + echo "${BASH_REMATCH[1]}w ago" + return 0 + fi + if [[ $value =~ ^([0-9]+)[[:space:]]+months?\ ago$ ]]; then + echo "${BASH_REMATCH[1]}m ago" + return 0 + fi + if [[ $value =~ ^([0-9]+)[[:space:]]+month\(s\)\ ago$ ]]; then + echo "${BASH_REMATCH[1]}m ago" + return 0 + fi + if [[ $value =~ ^([0-9]+)[[:space:]]+years?\ ago$ ]]; then + echo "${BASH_REMATCH[1]}y ago" + return 0 + fi + echo "$value" +} diff --git a/lib/ui/app_selector.sh b/lib/ui/app_selector.sh index f8c63e1..96348d9 100755 --- a/lib/ui/app_selector.sh +++ b/lib/ui/app_selector.sh @@ -7,41 +7,31 @@ set -euo pipefail format_app_display() { local display_name="$1" size="$2" last_used="$3" - # Compact last-used wording to keep column width tidy + # Use common function from ui.sh to format last used time local compact_last_used - case "$last_used" in - "" | "Unknown") compact_last_used="Unknown" ;; - "Never" | "Recent" | "Today" | "Yesterday" | "This year" | "Old") compact_last_used="$last_used" ;; - *) - if [[ $last_used =~ ^([0-9]+)[[:space:]]+days?\ ago$ ]]; then - compact_last_used="${BASH_REMATCH[1]}d ago" - elif [[ $last_used =~ ^([0-9]+)[[:space:]]+weeks?\ ago$ ]]; then - compact_last_used="${BASH_REMATCH[1]}w ago" - elif [[ $last_used =~ ^([0-9]+)[[:space:]]+months?\ ago$ ]]; then - compact_last_used="${BASH_REMATCH[1]}m ago" - elif [[ $last_used =~ ^([0-9]+)[[:space:]]+month\(s\)\ ago$ ]]; then - compact_last_used="${BASH_REMATCH[1]}m ago" - elif [[ $last_used =~ ^([0-9]+)[[:space:]]+years?\ ago$ ]]; then - compact_last_used="${BASH_REMATCH[1]}y ago" - else - compact_last_used="$last_used" - fi - ;; - esac - - # Truncate long names with consistent width - local truncated_name="$display_name" - if [[ ${#display_name} -gt 22 ]]; then - truncated_name="${display_name:0:19}..." - fi + compact_last_used=$(format_last_used_summary "$last_used") # Format size local size_str="Unknown" [[ "$size" != "0" && "$size" != "" && "$size" != "Unknown" ]] && size_str="$size" - # Use consistent column widths for perfect alignment: - # name column (22), right-aligned size column (9), then compact last-used value. - printf "%-22s %9s | %s" "$truncated_name" "$size_str" "$compact_last_used" + # Calculate available width for app name based on terminal width + local terminal_width=$(tput cols 2>/dev/null || echo 80) + local fixed_width=28 + local available_width=$((terminal_width - fixed_width)) + + # Set reasonable bounds for name width: 24-35 chars + [[ $available_width -lt 24 ]] && available_width=24 + [[ $available_width -gt 35 ]] && available_width=35 + + # Truncate long names if needed + local truncated_name="$display_name" + if [[ ${#display_name} -gt $available_width ]]; then + truncated_name="${display_name:0:$((available_width - 3))}..." + fi + + # Use dynamic column width for better readability + printf "%-*s %9s | %s" "$available_width" "$truncated_name" "$size_str" "$compact_last_used" } # Global variable to store selection result (bash 3.2 compatible) diff --git a/mole b/mole index c6d2e55..d3328e9 100755 --- a/mole +++ b/mole @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib/core/common.sh" # Version info -VERSION="1.12.2" +VERSION="1.12.3" MOLE_TAGLINE="can dig deep to clean your Mac." # Check if Touch ID is already configured