mirror of
https://github.com/tw93/Mole.git
synced 2026-02-14 15:17:26 +00:00
Optimize the key usage experience
This commit is contained in:
28
bin/clean.sh
28
bin/clean.sh
@@ -460,25 +460,25 @@ start_cleanup() {
|
||||
|
||||
if [[ -t 0 ]]; then
|
||||
echo ""
|
||||
echo -ne "${PURPLE}${ICON_ARROW}${NC} System caches need sudo — ${GREEN}Enter${NC} continue, other key skip: "
|
||||
echo -ne "${PURPLE}${ICON_ARROW}${NC} System caches need sudo — ${GREEN}Enter${NC} continue, ${GRAY}Space${NC} skip: "
|
||||
|
||||
# Use IFS= and read without -n to allow Ctrl+C to work properly
|
||||
IFS= read -r -s -n 1 choice
|
||||
local read_status=$?
|
||||
# Use read_key to properly handle all key inputs
|
||||
local choice
|
||||
choice=$(read_key)
|
||||
|
||||
# If read was interrupted (Ctrl+C), exit cleanly
|
||||
if [[ $read_status -ne 0 ]]; then
|
||||
echo ""
|
||||
exit 130
|
||||
fi
|
||||
|
||||
if [[ "$choice" == $'\e' ]]; then
|
||||
# Check for cancel (ESC or Q)
|
||||
if [[ "$choice" == "QUIT" ]]; then
|
||||
echo -e " ${GRAY}Cancelled${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Space = skip
|
||||
if [[ "$choice" == "SPACE" ]]; then
|
||||
echo -e " ${GRAY}Skipped${NC}"
|
||||
echo ""
|
||||
SYSTEM_CLEAN=false
|
||||
# Enter = yes, do system cleanup
|
||||
if [[ -z "$choice" ]] || [[ "$choice" == $'\n' ]]; then
|
||||
elif [[ "$choice" == "ENTER" ]]; then
|
||||
printf "\r\033[K" # Clear the prompt line
|
||||
if request_sudo_access "System cleanup requires admin access"; then
|
||||
SYSTEM_CLEAN=true
|
||||
@@ -514,10 +514,8 @@ start_cleanup() {
|
||||
echo -e "${YELLOW}Authentication failed${NC}, continuing with user-level cleanup"
|
||||
fi
|
||||
else
|
||||
# ESC or other key = no system cleanup
|
||||
# Other keys (including arrow keys) = skip, no message needed
|
||||
SYSTEM_CLEAN=false
|
||||
echo ""
|
||||
echo -e "${GRAY}Skipped system cleanup, user-level only${NC}"
|
||||
fi
|
||||
else
|
||||
SYSTEM_CLEAN=false
|
||||
|
||||
Reference in New Issue
Block a user