diff --git a/bin/analyze-go b/bin/analyze-go index e3fc388..96d1059 100755 Binary files a/bin/analyze-go and b/bin/analyze-go differ diff --git a/cmd/analyze/main.go b/cmd/analyze/main.go index c1b7bd5..6eae00e 100644 --- a/cmd/analyze/main.go +++ b/cmd/analyze/main.go @@ -1042,15 +1042,15 @@ func (m model) View() string { fmt.Fprintln(&b) if m.inOverviewMode() { - fmt.Fprintf(&b, "%s↑/↓ Nav | Enter | O Open | F Reveal | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓→ | Enter | O Open | F Reveal | Q Quit%s\n", colorGray, colorReset) } else if m.showLargeFiles { - fmt.Fprintf(&b, "%s↑/↓ Nav | O Open | F Reveal | ⌫ Delete | L Back | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓ | O Open | F Reveal | ⌫ Delete | L Back | Q Quit%s\n", colorGray, colorReset) } else { largeFileCount := len(m.largeFiles) if largeFileCount > 0 { - fmt.Fprintf(&b, "%s↑/↓/←/→ Nav | Enter | O Open | F Reveal | ⌫ Delete | L Large(%d) | Q Quit%s\n", colorGray, largeFileCount, colorReset) + fmt.Fprintf(&b, "%s↑↓←→ | Enter | O Open | F Reveal | ⌫ Delete | L Large(%d) | Q Quit%s\n", colorGray, largeFileCount, colorReset) } else { - fmt.Fprintf(&b, "%s↑/↓/←/→ Nav | Enter | O Open | F Reveal | ⌫ Delete | Q Quit%s\n", colorGray, colorReset) + fmt.Fprintf(&b, "%s↑↓←→ | Enter | O Open | F Reveal | ⌫ Delete | Q Quit%s\n", colorGray, colorReset) } } if m.deleteConfirm && m.deleteTarget != nil { diff --git a/lib/common.sh b/lib/common.sh index 8f01542..925ddd8 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -287,6 +287,7 @@ read_key() { ' ') echo "SPACE" ;; 'q' | 'Q') echo "QUIT" ;; 'h' | 'H') echo "HELP" ;; + 'v' | 'V') echo "VERSION" ;; 'R') echo "RETRY" ;; 'o' | 'O') echo "OPEN" ;; '/') echo "FILTER" ;; diff --git a/lib/menu_paginated.sh b/lib/menu_paginated.sh index 9521e87..818d994 100755 --- a/lib/menu_paginated.sh +++ b/lib/menu_paginated.sh @@ -356,7 +356,7 @@ paginated_multi_select() { for ((i = 0; i < items_per_page + 2; i++)); do printf "${clear_line}\n" >&2 done - printf "${clear_line}Type to filter | Delete | Enter | / Exit | ESC\n" >&2 + printf "${clear_line}${GRAY}Type to filter | Delete | Enter | / Exit | ESC${NC}\n" >&2 printf "${clear_line}" >&2 return else @@ -365,7 +365,7 @@ paginated_multi_select() { for ((i = 0; i < items_per_page + 2; i++)); do printf "${clear_line}\n" >&2 done - printf "${clear_line}${ICON_NAV_UP}/${ICON_NAV_DOWN} | Space | Enter | / Filter | Q Exit\n" >&2 + printf "${clear_line}${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN} | Space | Enter | / Filter | Q Exit${NC}\n" >&2 printf "${clear_line}" >&2 return else @@ -374,7 +374,7 @@ paginated_multi_select() { for ((i = 0; i < items_per_page + 2; i++)); do printf "${clear_line}\n" >&2 done - printf "${clear_line}${ICON_NAV_UP}/${ICON_NAV_DOWN} | Space | Enter | / Filter | Q Exit\n" >&2 + printf "${clear_line}${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN} | Space | Enter | / Filter | Q Exit${NC}\n" >&2 printf "${clear_line}" >&2 return fi @@ -431,15 +431,15 @@ paginated_multi_select() { fi # Footer: single line with controls - local sep=" | " + local sep=" ${GRAY}|${NC} " if [[ "$filter_mode" == "true" ]]; then # Filter mode: simple controls without sort local -a _segs_filter=( - "Filter: ${filter_status}" - "Delete" - "Enter" - "/ Exit" - "ESC" + "${GRAY}Filter: ${filter_status}${NC}" + "${GRAY}Delete${NC}" + "${GRAY}Enter${NC}" + "${GRAY}/ Exit${NC}" + "${GRAY}ESC${NC}" ) _print_wrapped_controls "$sep" "${_segs_filter[@]}" else @@ -455,34 +455,34 @@ paginated_multi_select() { if [[ -n "$applied_query" ]]; then # Filtering: hide sort controls local -a _segs_all=( - "${ICON_NAV_UP}/${ICON_NAV_DOWN}" - "Space" - "Enter" - "${filter_text}" - "Q Exit" + "${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}" + "${GRAY}Space${NC}" + "${GRAY}Enter${NC}" + "${GRAY}${filter_text}${NC}" + "${GRAY}Q Exit${NC}" ) _print_wrapped_controls "$sep" "${_segs_all[@]}" else # Normal: show full controls local -a _segs_all=( - "${ICON_NAV_UP}/${ICON_NAV_DOWN}" - "Space" - "Enter" - "${filter_text}" - "S ${sort_status}" - "R ${reverse_arrow}" - "Q Exit" + "${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}" + "${GRAY}Space${NC}" + "${GRAY}Enter${NC}" + "${GRAY}${filter_text}${NC}" + "${GRAY}S ${sort_status}${NC}" + "${GRAY}R ${reverse_arrow}${NC}" + "${GRAY}Q Exit${NC}" ) _print_wrapped_controls "$sep" "${_segs_all[@]}" fi else # Without metadata: basic controls local -a _segs_simple=( - "${ICON_NAV_UP}/${ICON_NAV_DOWN}" - "Space" - "Enter" - "${filter_text}" - "Q Exit" + "${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN}${NC}" + "${GRAY}Space${NC}" + "${GRAY}Enter${NC}" + "${GRAY}${filter_text}${NC}" + "${GRAY}Q Exit${NC}" ) _print_wrapped_controls "$sep" "${_segs_simple[@]}" fi diff --git a/lib/menu_simple.sh b/lib/menu_simple.sh index 0c0073e..3829486 100755 --- a/lib/menu_simple.sh +++ b/lib/menu_simple.sh @@ -168,7 +168,7 @@ paginated_multi_select() { # Clear any remaining lines at bottom printf "${clear_line}\n" >&2 - printf "${clear_line}${ICON_NAV_UP}/${ICON_NAV_DOWN} | Space | Enter | Q Exit\n" >&2 + printf "${clear_line}${GRAY}${ICON_NAV_UP}${ICON_NAV_DOWN} | Space | Enter | Q Exit${NC}\n" >&2 # Clear one more line to ensure no artifacts printf "${clear_line}" >&2 diff --git a/mole b/mole index 3701716..cc00e64 100755 --- a/mole +++ b/mole @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib/common.sh" # Version info -VERSION="1.9.16" +VERSION="1.9.17" MOLE_TAGLINE="can dig deep to clean your Mac." # Get latest version from remote repository @@ -32,10 +32,25 @@ get_latest_version() { grep '^VERSION=' | head -1 | sed 's/VERSION="\(.*\)"/\1/' } +# Get latest version from Homebrew for brew-installed Mole +get_latest_brew_version() { + if ! command -v brew > /dev/null 2>&1; then + return 1 + fi + + brew info --json=v2 mole 2> /dev/null | grep -o '"version":"[^"]*"' | head -1 | sed 's/"version":"\(.*\)"/\1/' +} + +# Check if installed via Homebrew +is_homebrew_install() { + command -v brew > /dev/null 2>&1 && brew list mole > /dev/null 2>&1 +} + # Check for updates (non-blocking, cached) check_for_updates() { local cache="$HOME/.cache/mole/version_check" local msg_cache="$HOME/.cache/mole/update_message" + local debug_log="$HOME/.cache/mole/update_check_debug" local ttl="${MO_UPDATE_CHECK_TTL:-3600}" mkdir -p "$(dirname "$cache")" 2> /dev/null @@ -48,12 +63,28 @@ check_for_updates() { # Background version check (save to file, don't output) ( local latest - latest=$(get_latest_version) + local check_method="" + + # For Homebrew installations, check Homebrew version + if is_homebrew_install; then + latest=$(get_latest_brew_version) + check_method="brew" + [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): Checking via Homebrew, got: $latest" >> "$debug_log" + fi + + # Fallback to GitHub for non-brew or if brew check failed + if [[ -z "$latest" ]]; then + latest=$(get_latest_version) + check_method="github" + [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): Checking via GitHub, got: $latest" >> "$debug_log" + fi if [[ -n "$latest" && "$VERSION" != "$latest" && "$(printf '%s\n' "$VERSION" "$latest" | sort -V | head -1)" == "$VERSION" ]]; then printf "\nUpdate available: %s → %s, run %smo update%s\n\n" "$VERSION" "$latest" "$GREEN" "$NC" > "$msg_cache" + [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): Update available ($check_method): $VERSION → $latest" >> "$debug_log" else echo -n > "$msg_cache" + [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): No update needed ($check_method): $VERSION == $latest" >> "$debug_log" fi touch "$cache" 2> /dev/null ) & @@ -151,7 +182,7 @@ show_help() { # Simple update function update_mole() { # Check if installed via Homebrew - if command -v brew > /dev/null 2>&1 && brew list mole > /dev/null 2>&1; then + if is_homebrew_install; then update_via_homebrew "$VERSION" exit 0 fi @@ -279,7 +310,7 @@ remove_mole() { local -a alias_installs=() # Check Homebrew - if command -v brew > /dev/null 2>&1 && brew list mole > /dev/null 2>&1; then + if is_homebrew_install; then is_homebrew=true fi @@ -475,7 +506,7 @@ show_main_menu() { if [[ -t 0 ]]; then printf '\r\033[2K\n' - printf '\r\033[2K%s\n' "${GRAY}↑/↓ Nav ${GRAY}|${NC} ${GRAY}Enter${NC} Select ${GRAY}|${NC} ${GRAY}H${NC} Help ${GRAY}|${NC} ${GRAY}Q${NC} Quit" + printf '\r\033[2K%s\n' "${GRAY}↑↓ | Enter | H Help | V Version | Q Quit${NC}" printf '\r\033[2K\n' fi @@ -570,6 +601,12 @@ interactive_main_menu() { show_help exit 0 ;; + "VERSION") + show_cursor + clear + show_version + exit 0 + ;; "QUIT") cleanup_and_exit ;; esac done