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

feat(analyze): open current directory in Finder via "O" key (#19)

This commit is contained in:
huyixi
2025-10-09 14:43:18 +08:00
committed by GitHub
parent 56097e49a6
commit d34b617cb3
2 changed files with 20 additions and 1 deletions

View File

@@ -1610,6 +1610,7 @@ interactive_drill_down() {
local need_scan=true
local wait_for_calc=false # Don't wait on first load, let user press 'r'
local temp_items="$TEMP_PREFIX.items"
local status_message=""
# Cache variables to avoid recalculation
local -a items=()
@@ -1835,8 +1836,13 @@ interactive_drill_down() {
output+=$'\n'
fi
if [[ -n "$status_message" ]]; then
output+=" $status_message"$'\n\n'
status_message=""
fi
# Bottom help bar
output+=" ${GRAY}↑/↓${NC} Navigate ${GRAY}|${NC} ${GRAY}Enter${NC} Open ${GRAY}|${NC} ${GRAY}${NC} Back ${GRAY}|${NC} ${GRAY}Del${NC} Delete ${GRAY}|${NC} ${GRAY}Q/ESC${NC} Quit"$'\n'
output+=" ${GRAY}↑/↓${NC} Navigate ${GRAY}|${NC} ${GRAY}Enter${NC} Open ${GRAY}|${NC} ${GRAY}${NC} Back ${GRAY}|${NC} ${GRAY}Del${NC} Delete ${GRAY}|${NC} ${GRAY}O${NC} Finder ${GRAY}|${NC} ${GRAY}Q/ESC${NC} Quit"$'\n'
# Output everything at once (single write = no flicker)
printf "%b" "$output" >&2
@@ -1983,6 +1989,17 @@ interactive_drill_down() {
return 1 # Return to menu
fi
;;
"OPEN")
if command -v open >/dev/null 2>&1; then
if open "$current_path" >/dev/null 2>&1; then
status_message="${GREEN}${NC} Finder opened: ${GRAY}$current_path${NC}"
else
status_message="${YELLOW}Warning:${NC} Could not open ${GRAY}$current_path${NC}"
fi
else
status_message="${YELLOW}Warning:${NC} 'open' command not available"
fi
;;
"DELETE")
# Delete selected item (file or directory)
if [[ $cursor -lt ${#items[@]} ]]; then
@@ -2285,6 +2302,7 @@ main() {
echo " Enter / → Open selected folder"
echo " ← Go back to parent directory"
echo " Delete Delete selected file/folder (requires confirmation)"
echo " O Reveal current directory in Finder"
echo " Q / ESC Quit the explorer"
echo ""
echo "Features:"

View File

@@ -161,6 +161,7 @@ read_key() {
'd'|'D') echo "DELETE" ;;
'r'|'R') echo "RETRY" ;;
'?') echo "HELP" ;;
'o'|'O') echo "OPEN" ;;
$'\x03') echo "QUIT" ;; # Ctrl+C
$'\x7f'|$'\x08') echo "DELETE" ;; # Delete key (labeled "delete" on Mac, actually backspace)
$'\x1b')