1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:04:42 +00:00

🐛 change color

This commit is contained in:
Tw93
2025-10-05 22:37:43 +08:00
parent 518b04a759
commit c253e0ee60
8 changed files with 41 additions and 41 deletions

View File

@@ -720,7 +720,7 @@ display_cleanup_suggestions() {
echo "" echo ""
echo " ${YELLOW}Tip:${NC} Run 'mole clean' to perform cleanup operations" echo " ${YELLOW}Tip:${NC} Run 'mole clean' to perform cleanup operations"
else else
echo " ${BLUE}${NC} No obvious cleanup opportunities found" echo " ${GREEN}${NC} No obvious cleanup opportunities found"
fi fi
echo "" echo ""
} }
@@ -1858,7 +1858,7 @@ interactive_drill_down() {
open "$selected_path" 2>/dev/null && open_success=true open "$selected_path" 2>/dev/null && open_success=true
if [[ "$open_success" == "true" ]]; then if [[ "$open_success" == "true" ]]; then
echo "" echo ""
echo " ${BLUE}${NC} File opened in external app" echo " ${GREEN}${NC} File opened in external app"
sleep 0.8 sleep 0.8
fi fi
fi fi
@@ -1879,7 +1879,7 @@ interactive_drill_down() {
# Show brief success message # Show brief success message
if [[ "$open_success" == "true" ]]; then if [[ "$open_success" == "true" ]]; then
echo "" echo ""
echo " ${BLUE}${NC} File opened in external app" echo " ${GREEN}${NC} File opened in external app"
sleep 0.8 sleep 0.8
fi fi
fi fi
@@ -2002,7 +2002,7 @@ interactive_drill_down() {
fi fi
if [[ "$delete_success" == "true" ]]; then if [[ "$delete_success" == "true" ]]; then
echo " ${BLUE}✓ Deleted successfully${NC}" echo " ${GREEN}✓ Deleted successfully${NC}"
echo " ${GRAY}Freed: $human_size${NC}" echo " ${GRAY}Freed: $human_size${NC}"
sleep 0.8 sleep 0.8

View File

@@ -96,9 +96,9 @@ stop_spinner() {
kill "$SPINNER_PID" 2>/dev/null kill "$SPINNER_PID" 2>/dev/null
wait "$SPINNER_PID" 2>/dev/null wait "$SPINNER_PID" 2>/dev/null
SPINNER_PID="" SPINNER_PID=""
printf "\r ${BLUE}${NC} %s\n" "$result_message" printf "\r ${GREEN}${NC} %s\n" "$result_message"
else else
echo " ${BLUE}${NC} $result_message" echo " ${GREEN}${NC} $result_message"
fi fi
} }
@@ -235,7 +235,7 @@ safe_clean() {
if [[ "$DRY_RUN" == "true" ]]; then if [[ "$DRY_RUN" == "true" ]]; then
echo -e " ${YELLOW}${NC} $label ${YELLOW}($size_human, dry)${NC}" echo -e " ${YELLOW}${NC} $label ${YELLOW}($size_human, dry)${NC}"
else else
echo -e " ${BLUE}${NC} $label ${GREEN}($size_human)${NC}" echo -e " ${GREEN}${NC} $label ${GREEN}($size_human)${NC}"
fi fi
((files_cleaned+=total_count)) ((files_cleaned+=total_count))
((total_size_cleaned+=total_size_bytes)) ((total_size_cleaned+=total_size_bytes))
@@ -445,7 +445,7 @@ perform_cleanup() {
[[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning npm cache...\r" [[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning npm cache...\r"
npm cache clean --force >/dev/null 2>&1 || true npm cache clean --force >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} npm cache cleaned" echo -e " ${GREEN}${NC} npm cache cleaned"
note_activity note_activity
fi fi
@@ -458,7 +458,7 @@ perform_cleanup() {
[[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning pip cache...\r" [[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning pip cache...\r"
pip3 cache purge >/dev/null 2>&1 || true pip3 cache purge >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} pip cache cleaned" echo -e " ${GREEN}${NC} pip cache cleaned"
note_activity note_activity
fi fi
@@ -472,7 +472,7 @@ perform_cleanup() {
go clean -modcache >/dev/null 2>&1 || true go clean -modcache >/dev/null 2>&1 || true
go clean -cache >/dev/null 2>&1 || true go clean -cache >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} Go cache cleaned" echo -e " ${GREEN}${NC} Go cache cleaned"
note_activity note_activity
fi fi
@@ -487,7 +487,7 @@ perform_cleanup() {
[[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Docker build cache...\r" [[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Docker build cache...\r"
docker builder prune -af >/dev/null 2>&1 || true docker builder prune -af >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} Docker build cache cleaned" echo -e " ${GREEN}${NC} Docker build cache cleaned"
note_activity note_activity
fi fi
@@ -497,7 +497,7 @@ perform_cleanup() {
[[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Podman build cache...\r" [[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Podman build cache...\r"
podman system prune -f >/dev/null 2>&1 || true podman system prune -f >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} Podman build cache cleaned" echo -e " ${GREEN}${NC} Podman build cache cleaned"
note_activity note_activity
fi fi
safe_clean ~/.local/share/containers/storage/tmp/* "Container storage temp" safe_clean ~/.local/share/containers/storage/tmp/* "Container storage temp"
@@ -515,7 +515,7 @@ perform_cleanup() {
[[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Homebrew...\r" [[ -t 1 ]] && echo -ne " ${BLUE}${NC} Cleaning Homebrew...\r"
brew cleanup >/dev/null 2>&1 || true brew cleanup >/dev/null 2>&1 || true
[[ -t 1 ]] && echo -ne "\r\033[K" [[ -t 1 ]] && echo -ne "\r\033[K"
echo -e " ${BLUE}${NC} Homebrew cache cleaned" echo -e " ${GREEN}${NC} Homebrew cache cleaned"
note_activity note_activity
fi fi
@@ -785,7 +785,7 @@ perform_cleanup() {
fi fi
done done
local app_count=$(wc -l < "$installed_bundles" | tr -d ' ') local app_count=$(wc -l < "$installed_bundles" | tr -d ' ')
echo " ${BLUE}${NC} Found $app_count apps" echo " ${GREEN}${NC} Found $app_count apps"
local cache_count=0 local cache_count=0
@@ -805,7 +805,7 @@ perform_cleanup() {
fi fi
done done
fi fi
echo " ${BLUE}${NC} Complete ($cache_count removed)" echo " ${GREEN}${NC} Complete ($cache_count removed)"
# Clean up temp file # Clean up temp file
rm -f "$installed_bundles" rm -f "$installed_bundles"

View File

@@ -404,11 +404,11 @@ uninstall_applications() {
# Show what will be removed # Show what will be removed
echo -e " ${YELLOW}Files to be removed:${NC}" echo -e " ${YELLOW}Files to be removed:${NC}"
echo -e " ${BLUE}${NC} Application: $(echo "$app_path" | sed "s|$HOME|~|")" echo -e " ${GREEN}${NC} Application: $(echo "$app_path" | sed "s|$HOME|~|")"
# Show user-level files # Show user-level files
while IFS= read -r file; do while IFS= read -r file; do
[[ -n "$file" && -e "$file" ]] && echo -e " ${BLUE}${NC} $(echo "$file" | sed "s|$HOME|~|")" [[ -n "$file" && -e "$file" ]] && echo -e " ${GREEN}${NC} $(echo "$file" | sed "s|$HOME|~|")"
done <<< "$related_files" done <<< "$related_files"
# Show system-level files # Show system-level files
@@ -435,7 +435,7 @@ uninstall_applications() {
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
# Remove the application # Remove the application
if rm -rf "$app_path" 2>/dev/null; then if rm -rf "$app_path" 2>/dev/null; then
echo -e " ${BLUE}${NC} Removed application" echo -e " ${GREEN}${NC} Removed application"
else else
log_error "Failed to remove $app_path" log_error "Failed to remove $app_path"
continue continue
@@ -445,7 +445,7 @@ uninstall_applications() {
while IFS= read -r file; do while IFS= read -r file; do
if [[ -n "$file" && -e "$file" ]]; then if [[ -n "$file" && -e "$file" ]]; then
if rm -rf "$file" 2>/dev/null; then if rm -rf "$file" 2>/dev/null; then
echo -e " ${BLUE}${NC} Removed $(echo "$file" | sed "s|$HOME|~|" | xargs basename)" echo -e " ${GREEN}${NC} Removed $(echo "$file" | sed "s|$HOME|~|" | xargs basename)"
fi fi
fi fi
done <<< "$related_files" done <<< "$related_files"
@@ -456,7 +456,7 @@ uninstall_applications() {
while IFS= read -r file; do while IFS= read -r file; do
if [[ -n "$file" && -e "$file" ]]; then if [[ -n "$file" && -e "$file" ]]; then
if sudo rm -rf "$file" 2>/dev/null; then if sudo rm -rf "$file" 2>/dev/null; then
echo -e " ${BLUE}${NC} Removed [System] $(basename "$file")" echo -e " ${GREEN}${NC} Removed [System] $(basename "$file")"
else else
log_warning "Failed to remove system file: $file" log_warning "Failed to remove system file: $file"
fi fi

View File

@@ -458,7 +458,7 @@ perform_update() {
if echo "$upgrade_output" | grep -q "already installed"; then if echo "$upgrade_output" | grep -q "already installed"; then
local current_version local current_version
current_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}') current_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}')
echo -e "${BLUE}${NC} Already on latest version (${current_version:-$VERSION})" echo -e "${GREEN}${NC} Already on latest version (${current_version:-$VERSION})"
elif echo "$upgrade_output" | grep -q "Error:"; then elif echo "$upgrade_output" | grep -q "Error:"; then
log_error "Homebrew upgrade failed" log_error "Homebrew upgrade failed"
echo "$upgrade_output" | grep "Error:" >&2 echo "$upgrade_output" | grep "Error:" >&2
@@ -467,7 +467,7 @@ perform_update() {
echo "$upgrade_output" | grep -Ev "^(==>|Updating Homebrew|Warning:)" || true echo "$upgrade_output" | grep -Ev "^(==>|Updating Homebrew|Warning:)" || true
local new_version local new_version
new_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}') new_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}')
echo -e "${BLUE}${NC} Updated to latest version (${new_version:-$VERSION})" echo -e "${GREEN}${NC} Updated to latest version (${new_version:-$VERSION})"
fi fi
rm -f "$HOME/.cache/mole/version_check" "$HOME/.cache/mole/update_message" rm -f "$HOME/.cache/mole/version_check" "$HOME/.cache/mole/update_message"
@@ -494,7 +494,7 @@ perform_update() {
fi fi
if [[ "$installed_version" == "$target_version" ]]; then if [[ "$installed_version" == "$target_version" ]]; then
echo -e "${BLUE}${NC} Already on latest version ($installed_version)" echo -e "${GREEN}${NC} Already on latest version ($installed_version)"
exit 0 exit 0
fi fi
@@ -514,7 +514,7 @@ perform_update() {
updated_version="$target_version" updated_version="$target_version"
fi fi
echo -e "${BLUE}${NC} Updated to latest version ($updated_version)" echo -e "${GREEN}${NC} Updated to latest version ($updated_version)"
} }
# Run requested action # Run requested action

View File

@@ -185,14 +185,14 @@ batch_uninstall_applications() {
if [[ "$needs_sudo" == "true" ]]; then if [[ "$needs_sudo" == "true" ]]; then
if sudo rm -rf "$app_path" 2>/dev/null; then if sudo rm -rf "$app_path" 2>/dev/null; then
removal_success=true removal_success=true
echo -e " ${BLUE}${NC} Removed application" echo -e " ${GREEN}${NC} Removed application"
else else
error_msg="Failed to remove with sudo (check permissions or SIP protection)" error_msg="Failed to remove with sudo (check permissions or SIP protection)"
fi fi
else else
if rm -rf "$app_path" 2>/dev/null; then if rm -rf "$app_path" 2>/dev/null; then
removal_success=true removal_success=true
echo -e " ${BLUE}${NC} Removed application" echo -e " ${GREEN}${NC} Removed application"
else else
error_msg="Failed to remove (check if app is running or protected)" error_msg="Failed to remove (check if app is running or protected)"
fi fi
@@ -211,7 +211,7 @@ batch_uninstall_applications() {
done <<< "$related_files" done <<< "$related_files"
if [[ $files_removed -gt 0 ]]; then if [[ $files_removed -gt 0 ]]; then
echo -e " ${BLUE}${NC} Cleaned $files_removed related files" echo -e " ${GREEN}${NC} Cleaned $files_removed related files"
fi fi
((total_size_freed += total_kb)) ((total_size_freed += total_kb))

View File

@@ -36,7 +36,7 @@ log_info() {
log_success() { log_success() {
rotate_log rotate_log
echo -e " ${BLUE}${NC} $1" echo -e " ${GREEN}${NC} $1"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SUCCESS: $1" >> "$LOG_FILE" 2>/dev/null || true echo "[$(date '+%Y-%m-%d %H:%M:%S')] SUCCESS: $1" >> "$LOG_FILE" 2>/dev/null || true
} }
@@ -276,7 +276,7 @@ update_via_homebrew() {
# Get current version # Get current version
local current_version local current_version
current_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}') current_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}')
echo -e "${BLUE}${NC} Already on latest version (${current_version:-$version})" echo -e "${GREEN}${NC} Already on latest version (${current_version:-$version})"
elif echo "$upgrade_output" | grep -q "Error:"; then elif echo "$upgrade_output" | grep -q "Error:"; then
log_error "Homebrew upgrade failed" log_error "Homebrew upgrade failed"
echo "$upgrade_output" | grep "Error:" >&2 echo "$upgrade_output" | grep "Error:" >&2
@@ -287,7 +287,7 @@ update_via_homebrew() {
# Get new version # Get new version
local new_version local new_version
new_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}') new_version=$(brew list --versions mole 2>/dev/null | awk '{print $2}')
echo -e "${BLUE}${NC} Updated to latest version (${new_version:-$version})" echo -e "${GREEN}${NC} Updated to latest version (${new_version:-$version})"
fi fi
# Clear version check cache # Clear version check cache

View File

@@ -298,7 +298,7 @@ manage_whitelist() {
fi fi
if [[ ${#all_items[@]} -eq 0 ]]; then if [[ ${#all_items[@]} -eq 0 ]]; then
echo -e "${BLUE}${NC} No cache files found - system is clean!" echo -e "${GREEN}${NC} No cache files found - system is clean!"
echo "" echo ""
echo "Press any key to exit..." echo "Press any key to exit..."
read -n 1 -s read -n 1 -s
@@ -308,7 +308,7 @@ manage_whitelist() {
# Update global array with all items # Update global array with all items
AVAILABLE_CACHE_ITEMS=("${all_items[@]}") AVAILABLE_CACHE_ITEMS=("${all_items[@]}")
echo -e "${BLUE}${NC} Found ${#AVAILABLE_CACHE_ITEMS[@]} items" echo -e "${GREEN}${NC} Found ${#AVAILABLE_CACHE_ITEMS[@]} items"
echo "" echo ""
local -a menu_options=() local -a menu_options=()
@@ -432,7 +432,7 @@ EOF
fi fi
echo "" echo ""
echo -e "${BLUE}${NC} Protected $total_count items${summary}" echo -e "${GREEN}${NC} Protected $total_count items${summary}"
echo -e "${GRAY}Config: ${WHITELIST_CONFIG}${NC}" echo -e "${GRAY}Config: ${WHITELIST_CONFIG}${NC}"
} }

16
mole
View File

@@ -189,14 +189,14 @@ update_mole() {
echo "$install_output" | grep -Ev "^$" || true echo "$install_output" | grep -Ev "^$" || true
local new_version local new_version
new_version=$("$mole_path" --version 2>/dev/null | awk 'NF {print $NF}' || echo "") new_version=$("$mole_path" --version 2>/dev/null | awk 'NF {print $NF}' || echo "")
echo -e "${BLUE}✓${NC} Updated to latest version (${new_version:-unknown})" echo -e "${GREEN}✓${NC} Updated to latest version (${new_version:-unknown})"
else else
# Retry without --update flag # Retry without --update flag
if install_output=$("$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole" 2>&1); then if install_output=$("$tmp_installer" --prefix "$install_dir" --config "$HOME/.config/mole" 2>&1); then
echo "$install_output" | grep -Ev "^$" || true echo "$install_output" | grep -Ev "^$" || true
local new_version local new_version
new_version=$("$mole_path" --version 2>/dev/null | awk 'NF {print $NF}' || echo "") new_version=$("$mole_path" --version 2>/dev/null | awk 'NF {print $NF}' || echo "")
echo -e "${BLUE}✓${NC} Updated to latest version (${new_version:-unknown})" echo -e "${GREEN}✓${NC} Updated to latest version (${new_version:-unknown})"
else else
rm -f "$tmp_installer" rm -f "$tmp_installer"
log_error "Update failed" log_error "Update failed"
@@ -259,28 +259,28 @@ remove_mole() {
echo "" echo ""
if [[ "$is_homebrew" == "true" ]]; then if [[ "$is_homebrew" == "true" ]]; then
echo -e " ${BLUE}✓${NC} Mole (via Homebrew)" echo -e " ${GREEN}✓${NC} Mole (via Homebrew)"
fi fi
if [[ ${#manual_installs[@]} -gt 0 ]]; then if [[ ${#manual_installs[@]} -gt 0 ]]; then
for install in "${manual_installs[@]}"; do for install in "${manual_installs[@]}"; do
echo -e " ${BLUE}✓${NC} $install" echo -e " ${GREEN}✓${NC} $install"
local install_dir="$(dirname "$install")" local install_dir="$(dirname "$install")"
local install_root="$(dirname "$install_dir")" local install_root="$(dirname "$install_dir")"
if [[ -d "$install_root/lib" ]]; then if [[ -d "$install_root/lib" ]]; then
echo -e " ${BLUE}✓${NC} $install_root/lib/" echo -e " ${GREEN}✓${NC} $install_root/lib/"
fi fi
done done
fi fi
if [[ ${#alias_installs[@]} -gt 0 ]]; then if [[ ${#alias_installs[@]} -gt 0 ]]; then
for alias in "${alias_installs[@]}"; do for alias in "${alias_installs[@]}"; do
echo -e " ${BLUE}✓${NC} $alias" echo -e " ${GREEN}✓${NC} $alias"
done done
fi fi
echo -e " ${BLUE}✓${NC} ~/.config/mole/ (configuration)" echo -e " ${GREEN}✓${NC} ~/.config/mole/ (configuration)"
echo -e " ${BLUE}✓${NC} ~/.cache/mole/ (cache)" echo -e " ${GREEN}✓${NC} ~/.cache/mole/ (cache)"
if [[ "$is_homebrew" == "false" && ${#manual_installs[@]} -eq 0 && ${#alias_installs[@]} -eq 0 ]]; then if [[ "$is_homebrew" == "false" && ${#manual_installs[@]} -eq 0 && ${#alias_installs[@]} -eq 0 ]]; then
echo "" echo ""