How to Chain Multiple Commands in Raycast

If you have ever wondered if it’s possible to chain Raycast commands so that they run sequentially from just a single alias or hotkey, read on. This post will teach you how.

The other day, I was browsing the Raycast subreddit and stumbled upon this post:

Reddit post on Is is possible to chain multiple Raycast commands and assign them an alias?

Essentially, the user was asking if there was a way to execute a chain of commands in Raycast. The thread had some excellent suggestions about deeplinks and scripting but none of them had listed out the steps to tell exactly how.

Challenge accepted!

Up until that point, I had never heard of deeplinks in Raycast, so naturally, I headed straight to their deeplinks guide and devoured it.

I then experimented a little and found the perfect solution. Turns out, not only can you chain multiple Raycast commands, but you can also assign an alias or keyboard shortcut to execute them directly.

Also read: 4 Awesome Tricks to Change the Default Fonts in Excalidraw

It just involves your Mac’s native shortcuts app. Let’s now jump right into the tutorial.

What are deeplinks in Raycast

To utilize Raycast commands, you don’t have to have the Raycast app open.

For example, if you are on your Mac (with Raycast installed), you can make confetti appear right on your browser screen by following these steps:

Open a new tab → type raycast://confetti in the address bar and hit enter. Your browser may ask you to confirm if you want to “open”. Allow it and boom, you will have confetti showing on your screen.

Similarly, to run this command from your terminal, you’d use it like this:

open -g raycast://confetti
How to Chain Multiple Commands in Raycast
open is the native terminal command to open Apps, links, files, etc.

(The -g flag is used so that the Raycast app doesn’t steal the focus from the terminal window after this command is run. It ensures that the Raycast command is run in the background.)

See, every command in Raycast has a URL-type link (called deeplink) which can be executed from other programs such as the browser’s address bar, your Mac’s terminal, or any other app.

They are of the format raycast://extensions/<author-or-owner>/<extension-name>/<command-name> and are available for all commands in Raycast.

To copy the deeplink for any command, open Raycast → search for the command → Press the keyboard shortcut Shift (⇧) + Command (⌘) + C. Alternatively, you can copy the deeplink from the Actions menu (Cmd + K) of the command.

How to copy the deeplink to any command in Raycast

How to chain multiple commands in Raycast

To execute two or more commands one after the other, we will need to run them through a shell script. We will first create a shell script with the deeplinks for the commands we want to execute, then we will execute them with the help of the Shortcut app.

Let’s see how we can solve the problem we started this blog post with. The OP wants to do the following:

  1. First, execute the Almost Maximize on a focused window
  2. Then, execute Maximum Height on that window.

To do this, we’ll need the deeplinks for both of these commands. I grabbed the deeplinks for both of them and put them sequentially:

open -g raycast://extensions/raycast/window-management/almost-maximize

open -g raycast://extensions/raycast/window-management/maximize-height

One thing to keep in mind is that the window management features (such as resizing) require the active window to be focused, otherwise they won’t work. To ensure that the Raycast app doesn’t steal the focus, the -g flag is a must.

Now we are ready to create a shortcut for this command.

Creating a shortcut to run multiple Raycast commands through a shell script

Open the shortcuts app on your Mac (Press Cmd + Space and search for Then, click on the + symbol at the top bar of this app. A new window will open where you can create your shortcut.

At the top bar of this window, Click on “Shortcut name” and give an appropriate name to your shortcut. This name will be used from Raycast to run this script.

Then in the right side search box, type “shell script”, then drag the “Run Shell Script” tab to the main editing area.

How to create a shortcut for a shell script through the on Mac

Now, delete the text echo "Hello World" with the deeplink commands we copied above. This is what your final shortcut window should look like:

how to chain multiple raycast commands through Shell script on the shortcuts app

You can test out this window by clicking on the ‘▶︎’ button on the toolbar. You may be prompted if Raycast should run this command. Click on “Always run command” and it should work.

Your shortcut has now been created. You can now safely close the shortcut app window (Cmd + W).

Must read: Why Raycast has the Best Clipboard Manager on Mac

You can now execute this shortcut directly from Raycast. Just launch Raycast → search for the shortcut’s name → hit enter.

To speed up the workflow even more, you can give it an alias or tie it to a global hotkey. To do so, launch Raycast → search for ‘extensions’ → scroll to the shortcut’s name.

How to create an alias and hotkey for any Raycast command

Now, you know how to tie shortcuts to the multiple Raycast commands so that they run sequentially.

So, what else can you do with it?

Plenty, as it turns out. The possibilities are endless.

I have thought of several scenarios where chaining of commands can be useful.

1. Opening apps in full screen

If you have an app that you always use in full screen (such as the Books app), you can chain the commands to open the app and make it full screen.

Here’s what terminal commands would look like:

open -a Books && osascript -e 'tell application "Books" to activate'

open -g raycast://extensions/raycast/window-management/maximize

The command open -a Books opens the Books app, while the next osascript command focuses this app so that it can be maximized by the upcoming Raycast command.

Fullscreen is just a size, you can customize this sequence for any of the window sizes offered by Raycast.

To open it at 90% of the size of your screen, replace the ‘maximize’ word with ‘almost-maximize’ at the end of the second command.

2. Open multiple apps and tile them side by side

If you frequently use two (or more) apps together, you might wanna create a workflow where a single shortcut opens both of them and arranges them side by side.

Suppose that I use the Arc browser and the Dictionary app together on my Mac, where the Arc app occupies the left three-fourths of the screen and the Dictionary app lies in the last fourth. This is what my terminal command will look like:

# Open arc
open /Applications/

#Open dictionary app and focus it
open -a Dictionary && osascript -e 'tell application "Dictionary" to activate'

# Shrink dictionary to last-fourth of screen
open -g raycast://extensions/raycast/window-management/last-fourth

# Focus on the Arc app
osascript -e 'tell application "/Applications/" to activate'

# Tile Arc on first three fourths
open -g raycast://extensions/raycast/window-management/first-three-fourths

Note that you might be prompted for permission to run these commands once or twice. Click on “Always run command” to allow it.

Also, keep in mind that not all apps support all window sizes offered by Raycast. For example, the Books app’s main window cannot be made smaller than half the screen. So, some of the terminal commands we are writing may behave a little unexpectedly.

Wrap up

I hope you got an idea of how you can chain multiple commands in Raycast so that they run one after the other. The key is to identify the workflow you use frequently and then convert it into a concrete series of steps that can be run using shell scripts.

The possibilities for its application are endless. These are just the ones I quickly came up with.

Thanks for reading. If you liked this article, don’t forget to share it on social media.

Also read: How to Automatically Compress Screenshots on Mac