My First Raycast Script
Context
I use Raycast as my central application / task launcher. You should check it out if you are running OSX because it is pretty cool!
So far, I mainly use it to launch applications or open web-pages, but there are many more things that you can use it to do. One of those things is running custom scripts.
My Problem
I often save things I am working on in the moment to my Desktop. It's a good visual indicator that I have things that I need to process, but eventually things get cluttered. What I usually do is at some point at the end of the day, I will make sure I'm done with all these things, then I manually select everything on the Desktop and send everything to the trash.
But I think I can do better. This seems like a perfect job for my first Raycast script.

So, how do we do it?
The best documentation around this seems to be on the GitHub: raycast/script-commands README. Here you can find context, instructions, as well as example script commands.
Based on the documentation, we simply place a script, augmented with specific metadata, in a directory, and tell Raycast to look in this directory for script-commands.
I took the simplest example I could find as my starting point and changed it for my purpose.
#!/bin/bash
# Dependency: requires trash
# Install with Homebrew: `brew install trash`
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Clean Desktop
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🗑️
# @raycast.packageName Desktop Cleaner
trash $HOME/Desktop/*
Once you have this script created and placed somewhere on your file-system, all that's left is to:
- Make the script executable:
chmod u+x <your-script>
- Tell Raycast where to look for the script (see screenshot below)

Additional notes
Originally I was thinking all I would need to do is something like:
mv ~/Desktop/* ~/.Trash
But because of things like the possibility of conflicting filenames as well as OS-specific file recovery, the task becomes slightly more complicated For this reason, I decided to install and use a dependency:
- https://hasseg.org/trash