Sub topic 1
Meet the Shortcuts app and create your first shortcut
This chapter introduces the Shortcuts app on the Mac and walks you through building, naming and running a small shortcut. By the end you will know the parts of the editor, what happens when a shortcut runs, and the mistakes that most often trip up a first project.
Prerequisites
This chapter assumes you can do the following:
- Use Finder, open apps from the Applications folder and move around System Settings.
- Follow a step-by-step procedure and predict what each step does.
- Type a short command in Terminal. This is optional, and only the last section uses it.
You need a Mac running macOS Monterey (12) or later, because earlier versions do not include the Shortcuts app. Menu names and sidebar items shift a little between macOS releases. If something on your screen is labeled slightly differently, look for the closest match.
What a shortcut is
A shortcut is a saved sequence of actions. An action is one operation, such as asking the user for text, changing the case of text, or copying something to the clipboard. When you run the shortcut, macOS performs the actions from top to bottom. Most actions take the result of the action above as their input, and they produce a result of their own.
This chapter relies on three ideas:
- A shortcut is an ordered list. Order matters, and you can drag actions to reorder them.
- Data flows downward. An action's output normally becomes the next action's input.
- A shortcut has a name and a library entry. It is stored in your library and synced through iCloud if you have Shortcuts syncing turned on.
The Shortcuts app window
Open the app from Launchpad, from the Applications folder, or with Spotlight (Command-Space, then type "Shortcuts"). The window has three regions.
| Region | Where | What it does |
|---|---|---|
| Sidebar | Left | Lists your library. It has sections such as All Shortcuts, Quick Actions and Menu Bar, plus any folders you create. |
| Shortcut grid | Center | Shows each shortcut as a tile. Double-click a tile to open it in the editor. Click the tile's run button to run it. |
| Editor | Opens in the window when you open a shortcut | Holds the action list on the left and the action library on the right. |
The sidebar also has a Gallery, which holds ready-made shortcuts from Apple. Gallery shortcuts are good examples to read. After you add one to your library, open it and check what each action does.
The editor
When you open or create a shortcut, the editor shows:
- The shortcut's name at the top. Click it to rename.
- The action list, which is the script itself. Each action appears as a card with its parameters shown inline.
- A search field on the right for finding actions. Double-click a result, or drag it into the list, to add it.
- A Run button (a play triangle) in the toolbar. It runs the shortcut from the editor.
- An information button in the toolbar. It opens the shortcut's details, where you set things like keyboard shortcuts and where the shortcut appears.
Create your first shortcut
You will build a shortcut named Shout Back. It asks you for some text, converts it to uppercase, shows the result and copies it to the clipboard.
Step 1: Create and name it
- Choose File > New Shortcut, or press Command-N. An empty editor opens.
- Click the name at the top, type
Shout Back, and press Return.
Step 2: Add Ask for Input
- In the search field on the right, type
Ask for Input. - Double-click the result. A card appears in the action list.
- Leave the type as Text. In the prompt field, type
What should I say?.
Step 3: Add Change Case
- Search for
Change Caseand add it below the first action. - The card reads "Change Provided Input to capitalize" or similar. The blue token is the action's input, and it already points to the output of Ask for Input.
- Click the case option and choose UPPERCASE.
Step 4: Show and copy the result
- Search for
Show Resultand add it. Its input is the output of Change Case. - Search for
Copy to Clipboardand add it as the last step.
The finished list looks like this:
Step 5: Run it
Click the Run button in the toolbar. A dialog asks "What should I say?". Type hello world and click Done. A result window shows HELLO WORLD. Paste somewhere to confirm the clipboard holds the same text.
The first time an action touches something sensitive, macOS may show a permission prompt. Plain text actions like these do not need one.
How data flows between actions
The Shout Back shortcut works without any wiring from you. Each action implicitly passes its output to the next one. This is the "output feeds the next step" rule.
The rule has three consequences worth understanding now:
- An action that ignores its input still lets the data pass through. Some actions, like Show Result, return their input unchanged, which is why the clipboard step still receives the uppercase text.
- An action that produces a new value replaces the flow. If you insert a Text action between two others, the next action receives that new text, not the earlier value.
- You can reach back to an earlier result by clicking an input field and choosing a variable. The next chapter covers this.
Seeing the result of each action
After a run from the editor, hover over or click an action and look for a result preview. In Shortcuts on Mac, the Run button's progress also shows which action is executing. Use this to confirm each step produces what you expect. The debugging chapter covers this in depth.
Making the shortcut easy to reach
A shortcut that lives only in the library is slow to use. Open the details with the information button and consider these settings:
- Pin in Menu Bar shows the shortcut in the Shortcuts menu bar item.
- Use as Quick Action lets it appear in Finder or the Services menu. A Quick Action must declare what kind of input it accepts.
- Add Keyboard Shortcut assigns a key combination that must include at least one modifier key such as Command, Option or Control.
Later chapters cover each of these properly. For now, turn on Pin in Menu Bar for Shout Back and run it from the menu bar to see that it behaves the same.
Checking your shortcut from Terminal
The Shortcuts app installs a command-line tool named shortcuts. It confirms that your shortcut is saved under the exact name you gave it:
shortcuts listThe output is one shortcut name per line. If Shout Back appears, the library entry exists. A later chapter covers running shortcuts from Terminal.
Common errors
The shortcut runs but the result is wrong
Check the order of the actions. A very common mistake is adding an action at the end of the list when it belongs in the middle. Drag its card up to the right position.
An action shows an empty or missing input
If a card has an empty variable slot, or a red or placeholder token, the earlier action it referred to was deleted or moved below it. Click the field and choose a valid variable from the earlier steps. An action can only use results from actions above it.
The dialog never appears
If you ran the shortcut from the menu bar and nothing seems to happen, look for the Shortcuts window or dialog behind other windows. Shortcuts that need input open a prompt that can be hidden behind a full-screen app.
The name cannot be found later
Names are matched exactly when you run a shortcut from Terminal. A trailing space, different capitalization or a duplicate name causes a failure. Copy the name from shortcuts list instead of retyping it.
Edits seem to disappear
The editor saves changes automatically as you work. If you duplicate a shortcut to experiment, you now have two entries with similar names. Rename the copy right away so you know which one is which.
What you have learned
You can now open the Shortcuts app, tell the sidebar, grid and editor apart, create and name a shortcut, add actions from the search field, and run it from the editor and the menu bar. You also know the central rule that an action's output becomes the next action's input. The next chapter looks at actions more closely and shows how to control what each one receives.
Exercise
You build a shortcut with these actions in order: Ask for Input, Text (containing the words "Done!"), Change Case set to UPPERCASE, Show Result. You type hello at the prompt. What does Show Result display, and why?
Show answer
It shows DONE!. The Text action produces a new value, which replaces the data flowing down the list. Change Case therefore receives "Done!", not the typed hello, and Show Result displays the uppercase version of that text. To use the typed value, you would select the Provided Input variable in Change Case's input field.
Exercise
You renamed your shortcut to Shout Back with a trailing space, and shortcuts run "Shout Back" now fails. What is the most reliable way to fix the command, and how should you avoid the problem?
Show answer
Run shortcuts list, copy the exact name from its output, and use that in the command, or rename the shortcut in the editor to remove the trailing space. Names are matched exactly, so copy names instead of retyping them.