mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 11:31:46 +00:00
feat: Improve clean_local_snapshots robustness and simplify Raycast quick launcher setup.
This commit is contained in:
@@ -28,8 +28,6 @@ prompt_enter() {
|
||||
echo "$prompt"
|
||||
fi
|
||||
}
|
||||
RAYCAST_HINT_FILE="$HOME/.config/mole/raycast_script_dirs_added"
|
||||
|
||||
detect_mo() {
|
||||
if command -v mo > /dev/null 2>&1; then
|
||||
command -v mo
|
||||
@@ -234,75 +232,44 @@ EOF
|
||||
create_raycast_commands() {
|
||||
local mo_bin="$1"
|
||||
local default_dir="$HOME/Library/Application Support/Raycast/script-commands"
|
||||
local alt_dir="$HOME/Documents/Raycast/Scripts"
|
||||
local dirs=()
|
||||
|
||||
if [[ -d "$default_dir" ]]; then
|
||||
dirs+=("$default_dir")
|
||||
fi
|
||||
if [[ -d "$alt_dir" ]]; then
|
||||
dirs+=("$alt_dir")
|
||||
fi
|
||||
if [[ ${#dirs[@]} -eq 0 ]]; then
|
||||
dirs+=("$default_dir")
|
||||
fi
|
||||
local dir="$default_dir"
|
||||
|
||||
log_step "Installing Raycast commands..."
|
||||
for dir in "${dirs[@]}"; do
|
||||
mkdir -p "$dir"
|
||||
write_raycast_script "$dir/mole-clean.sh" "clean" "$mo_bin" "clean"
|
||||
write_raycast_script "$dir/mole-uninstall.sh" "uninstall" "$mo_bin" "uninstall"
|
||||
write_raycast_script "$dir/mole-optimize.sh" "optimize" "$mo_bin" "optimize"
|
||||
write_raycast_script "$dir/mole-analyze.sh" "analyze" "$mo_bin" "analyze"
|
||||
write_raycast_script "$dir/mole-status.sh" "status" "$mo_bin" "status"
|
||||
log_success "Scripts ready in: $dir"
|
||||
done
|
||||
mkdir -p "$dir"
|
||||
write_raycast_script "$dir/mole-clean.sh" "clean" "$mo_bin" "clean"
|
||||
write_raycast_script "$dir/mole-uninstall.sh" "uninstall" "$mo_bin" "uninstall"
|
||||
write_raycast_script "$dir/mole-optimize.sh" "optimize" "$mo_bin" "optimize"
|
||||
write_raycast_script "$dir/mole-analyze.sh" "analyze" "$mo_bin" "analyze"
|
||||
write_raycast_script "$dir/mole-status.sh" "status" "$mo_bin" "status"
|
||||
log_success "Scripts ready in: $dir"
|
||||
|
||||
log_header "Raycast Configuration"
|
||||
if open "raycast://extensions/raycast/raycast-settings/extensions" > /dev/null 2>&1; then
|
||||
log_step "Raycast settings opened."
|
||||
else
|
||||
log_warn "Could not auto-open Raycast."
|
||||
fi
|
||||
|
||||
if [[ -f "$RAYCAST_HINT_FILE" ]]; then
|
||||
echo "Raycast script directories already configured. Skipping manual setup."
|
||||
else
|
||||
for dir in "${dirs[@]}"; do
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo "Skipping: $dir (Directory does not exist)"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo -n "$dir" | pbcopy
|
||||
echo ""
|
||||
echo "--- Action Required for folder: $(basename "$dir") ---"
|
||||
echo "1. In the Raycast Extensions window, click the '+' icon."
|
||||
echo "2. Select 'Add Script Directory'."
|
||||
echo "3. A folder picker will open. Press: Shift + Command + G (⇧⌘G)."
|
||||
echo "4. Paste the path (manually) that is copied to your clipboard and press Enter."
|
||||
echo "5. Open / select the folder to confirm."
|
||||
echo ""
|
||||
echo "Path copied to your clipboard: $dir"
|
||||
|
||||
prompt_enter "Press [Enter] once you have added this folder..."
|
||||
done
|
||||
|
||||
if is_interactive; then
|
||||
mkdir -p "$(dirname "$RAYCAST_HINT_FILE")"
|
||||
touch "$RAYCAST_HINT_FILE"
|
||||
if command -v open > /dev/null 2>&1; then
|
||||
if open "raycast://extensions/raycast/raycast-settings/extensions" > /dev/null 2>&1; then
|
||||
log_step "Raycast settings opened."
|
||||
else
|
||||
log_warn "Could not auto-open Raycast."
|
||||
fi
|
||||
fi
|
||||
|
||||
log_header "Finalizing Setup"
|
||||
prompt_enter "In Raycast we need to reload the script directories to sync your new commands. Press [Enter] to reload..."
|
||||
if open "raycast://extensions/raycast/raycast/reload-script-directories" > /dev/null 2>&1; then
|
||||
log_step "Raycast script directories reloaded."
|
||||
else
|
||||
log_warn "Could not auto-reload Raycast script directories."
|
||||
log_warn "open command not available; please open Raycast manually."
|
||||
fi
|
||||
|
||||
log_success "Raycast setup complete!"
|
||||
echo "If Raycast asks to add a Script Directory, use:"
|
||||
echo " $dir"
|
||||
|
||||
if is_interactive; then
|
||||
log_header "Finalizing Setup"
|
||||
prompt_enter "Press [Enter] to reload script directories in Raycast..."
|
||||
if command -v open > /dev/null 2>&1 && open "raycast://extensions/raycast/raycast/reload-script-directories" > /dev/null 2>&1; then
|
||||
log_step "Raycast script directories reloaded."
|
||||
else
|
||||
log_warn "Could not auto-reload Raycast script directories."
|
||||
fi
|
||||
|
||||
log_success "Raycast setup complete!"
|
||||
else
|
||||
log_warn "Non-interactive mode; skip Raycast reload. Please run 'Reload Script Directories' in Raycast."
|
||||
fi
|
||||
}
|
||||
|
||||
uuid() {
|
||||
@@ -321,7 +288,6 @@ create_alfred_workflow() {
|
||||
local workflows_dir="$prefs_dir/workflows"
|
||||
|
||||
if [[ ! -d "$workflows_dir" ]]; then
|
||||
log_warn "Alfred preferences not found at $workflows_dir. Skipping Alfred workflow."
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user