DEV Community

Cover image for What **is** a script? 🤷🏼‍♀️ How can I use them with Raycast?

Posted on • Updated on

What **is** a script? 🤷🏼‍♀️ How can I use them with Raycast?

💚 Disclaimer: No prior knowledge needed...

Raycast is a productivity tool for MacOS, and as a native app, it fits in with the Mac styling and performance that you are used to. I'll be using Raycast as an easy way to show. you how to run and access scripts.

If you use Spotlight (hit cmd spacebar and you'll find it), then you will be more familiar with what Raycast is. There are many tools that you can use that are similar, such as Alfred, Automator, Launchbar and others. With all of these tools, you can search your entire computer for a file, you can search for things in the browser without even opening the browser and you can add commands (Alfred calls them workflows, Raycast calls them extensions) to speed up the things that you do the most often, such as opening a particular website, starting a new email or emptying the trash (my favourite command 🤓)

Personally, I find the Raycast UI to be much more natural for Mac and it has a strong community that can help with any questions, and I love how easy it is to install extensions, or scripts. It also is easier to extend and adapt to your personal workflows.

Also, right now it's totally free! 🥳

Hold up, what is a script?

A script is a code file that allows your computer to automate a set of instructions. This could be something relatively simple, such as opening a webpage in your default browser, or something more complex such as starting up your development environment and opening the browser as well as your IDE. Scripts run in the background - this means that they run without getting in your way, and they generally happen fast.

Writing a script is like writing a recipe for someone else to use - you give them exact ingredients and tell them what to do with those ingredients, and then they might make you a delicious meal!

A brightly coloured salad in a bowl


Scripts mean that you can instruct your computer to perform a set of instructions without having to ask you for anything.

Let's start with a script that does something that we all probably do too much but that probably isn't great for our productivity - opening Twitter in your default browser!

Luckily for us, the bash scripting language is pretty easy to remember for this script: the command word is open, so our script is going to be pretty short! Firstly, we need to install Raycast if you haven't already got it, and type Create Script Command as this will allow us to start coding straight away with all the metadata already set.

Script commands form in Raycast.

For this script, we are going to use Bash. The reason for this is because it is good for smaller and less complex scripts. Soon enough, you'll be coding with Ruby and Python and Swift and everything else, but for now let's get started with Bash.

After you've filled out the form, hit cmd+enter and choose where you'd like to save it. I recommend saving it in a folder called 'Code' if you don't have one already. If you're really stuck, just save it on the desktop and you can sort it out later 🥴

Now close Raycast for now, and go to the new file that you just made. Right-click, and go to Open With...

Right-click drop down box

I need to install some fancy tool though, right?


I'm using the built-in TextEdit Mac app, although you'll have a much better time if you have Visual Studio Code...

TextEdit window showing the code which is generated with the Create Script Command function

Ok, so we have our template, and we changed fullOutput to silent in the @raycast.mode(because we don't need to see any output or data for this script).

Would you believe me if I said we were nearly done?!

Next, we are going to write the actual script... hold onto your hats... 🧢

Enter fullscreen mode Exit fullscreen mode

Yep, it's really that easy! Congrats on writing your first script! Now, let's save it before we load it into Raycast. If, like me, you are using TextEdit for this, you'll need to change it to a 'plain text' file, under the format header, so that we can do what we want with it.

Next, you need to make a folder. I recommend saving it on on your desktop so you always remember where you put it! ✅ Now go back to your file and save it into your newly created folder. Name it anything you like, but make sure that the file ends in .sh. If it won't let you save it with the .sh file extension, go back and make sure that you remembered to make it a plain text file. If you aren't using TextEdit, then search for 'plain text' and the name of the text editor you are using in Google.

Now we can load it into Raycast!

🤓 Side note: As developers, we call folders on your computer directories. If they are on your computer, then they are local directories.

To load your script into Raycast, firstly open Raycast, then go to About, then Extensions, then click the little '+' to get to 'add script directory', find your folder, and then click open.

Ok, done!

Now we want to test our script, right?!

Go back to the root search of Raycast, and search for the title of your script! We set the @raycast.title to 'Open Twitter', so search for Open Twitter in Raycast and then hit enter on it...

Alt Text


Now, what happens if you change the URL and save the file, or if you add another open https://... ?

Suddenly, you have a way to open ALL of the web pages you need on a daily once!

Only web pages?

You can also open apps using the open command in bash - as long as you know the path to where the app is (usually /System/Volumes/Data/Applications/...)

Here's an example, my '' file. As the name suggests, this script opens everything I need for my workday!


# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Work
# @raycast.mode inline
# @raycast.description Open my workflows
# Optional parameters:
# @raycast.icon 💻
# @raycast.iconDark
# Credits
# Faye Sipiano
# @raycast.authorURL

open /System/Volumes/Data/Applications/
open /System/Volumes/Data/Applications/
open /System/Volumes/Data/Applications/
open /System/Volumes/Data/Applications/
Enter fullscreen mode Exit fullscreen mode

So that's how we can speed up our workflows using Raycast and open in bash scripts... what if you want to take it further..? What if you wanted to open a specific repo or file to work on? For that, you can add things like ~/Developer/raycast-web to tell it to open something in a specific place - you have given it the path (route) to get to it.

Scripting languages are cool and you can do a lot with them, but you don't need to remember how to write them...Google is your friend...

There're tonnes of workflows that you can speed up by loading scripts into Raycast. If you want inspiration or want to try out useful scripts written by the community, then head over to the community repo and see what you can find! One of my favourites is the Quit Everything command. I have it mapped to option q for extra drama. Obviously, I can't show you this script as my recorder would shut off, but it does what it says on the tin and it's a nice way of finishing off your workday in style 😎

I can't show you what it looks like, but it feels like this:

There are lots of scripts that you can write or download that will save you time and increase your productivity; take my usual, non-scripted, development workflow, for example:

Over 1 minute to get into my dev environment...

It takes over 1 minute to navigate to the right file and then use Gridsome to get into my dev environment

This is what I turned that into with the help of Raycast and a bash script:

8 Seconds!!! I save 63 seconds with this script.... that doesn't sound like A LOT, but trust me... it is A LOT if you are loading up your dev environment multiple times a day!!

I open Raycast, type 'dev' and hit enter. Everything loads up straight away and is 8 seconds from start to finish

That's Raycast! I hope that has inspired you to start looking into ways to speed up your workflows - head over to the community repo and see if you can find anything you like! As I mentioned, I personally recommend the Quit All Applications script and the Empty Trash script.

If you have any questions, recommendations or comments about Raycast or any of the repos or documentation, please reach out to me either through the community Slack channel - it is literally my job as a Developer Advocate to make sure that you get the best experience, regardless of your skill level 💚

Top comments (0)