← Back to Blog

How to Launch Claude Code with a Keyboard Shortcut

On a Mac, Keyboard Maestro can be set up to launch Claude Code with a single keyboard shortcut. The macro uses an AppleScript action that opens a new iTerm2 tab and types claude into it. The working approach uses write text rather than passing the command directly, because the direct method bypasses the shell profile and fails to find the claude executable. Terminal.app users can use the simpler do script approach.

What is Keyboard Maestro?

Keyboard Maestro is a Mac automation app ($36 one-time) that triggers sequences of actions with hotkeys. A “macro” is a named set of actions tied to a trigger. In this setup, pressing a keyboard shortcut runs an AppleScript that opens iTerm2 and starts Claude Code automatically.

One hotkey. iTerm opens, Claude starts. No typing, no navigating, no thinking about it.

Here’s how to set that up on a Mac using Keyboard Maestro.

What you need

  • Claude Code installed and working from your terminal
  • Keyboard Maestro (Mac automation app, $36 one-time, worth it)
  • iTerm2 (free, popular Mac terminal replacement) or the built-in Terminal.app

What is Keyboard Maestro? It’s a Mac app that lets you automate things on your computer by triggering actions with hotkeys, time conditions, or other triggers. A “macro” in Keyboard Maestro is just a named sequence of actions tied to a trigger. Press a key, something happens.

The setup

Step 1: Create a new macro

Open Keyboard Maestro Editor. Click the + button to create a new macro. Give it a name. “Claude Code” works. “Claude YOLO Mode” also works.

Step 2: Set your hotkey

Click the trigger area and press your shortcut physically on the keyboard. Something like Cmd+Shift+Y or Cmd+Shift+C. Don’t import a hotkey from a file or config, just press the actual keys. Imported hotkeys map wrong.

Step 3: Add an Execute AppleScript action

Click “New Action,” search for “Execute AppleScript,” and drag it into your macro. Paste this:

tell application "iTerm 2"
    activate
    tell current window
        create tab with default profile
        tell current session
            write text "claude"
        end tell
    end tell
end tell

What is AppleScript? It’s Mac’s built-in scripting language for controlling apps. It reads like English on purpose. This block is saying: “go to iTerm2, open a new tab with default settings, then type the word claude into that tab.”

Save the macro. Press your shortcut. iTerm opens a new tab and Claude Code starts.

The gotcha you’ll hit

If you look at the code above and think “there’s a simpler way to write that,” you’re right, but it won’t work.

The cleaner version looks like this:

tell application "iTerm 2"
    activate
    create window with default profile command "claude"
end tell

One problem: it’ll throw a “No such file or directory” error and you’ll stare at it for a few minutes.

Here’s why. When you pass a command directly to create window, iTerm bypasses your shell profile. Your shell profile is the file that runs automatically when you open a new terminal tab. On a Mac it’s usually ~/.zshrc. That file sets up your PATH.

What is PATH? It’s the list of directories your computer searches when you type a command. When you type claude, your terminal looks through your PATH for a file named claude. If it doesn’t find one, it fails.

What is .zshrc? It’s a config file in your home directory (the ~ means home). Every time a new terminal tab opens, .zshrc runs, which sets up your environment. Tools installed through nvm (a Node version manager) add themselves to PATH inside .zshrc. If .zshrc never runs, those tools are invisible.

The write text approach in the working version opens a new tab the normal way, which runs .zshrc, which sets up PATH, which means claude is findable. Less elegant in the script. Works every time in practice.

If you use Terminal.app instead of iTerm

The Terminal.app version is simpler:

tell application "Terminal"
    activate
    do script "claude"
end tell

Terminal’s do script loads your shell profile automatically. No workaround needed.

If you also want max effort by default, see Claude Code Max Effort Level Keeps Resetting for the alias approach. You can combine both.

For managing multiple sessions once you’re launching them fast, tmux for Claude Code Users is the next step.

Further reading

Common Questions

How do I launch Claude Code with a keyboard shortcut on Mac?

Use Keyboard Maestro to create a macro with an AppleScript action. The script tells iTerm2 to open a new tab and type claude. Set your preferred hotkey (like Cmd+Shift+C) as the trigger. Press the shortcut, and Claude Code starts.

Why does my AppleScript say “No such file or directory” when launching Claude Code?

The create window with default profile command "claude" approach bypasses your shell profile (.zshrc), which means PATH isn’t set up and the system can’t find the claude executable. Use write text "claude" in a new tab instead, which loads your profile first.

What is PATH in the terminal?

PATH is the list of directories your computer searches when you type a command. Tools installed via nvm or Homebrew add themselves to PATH inside your .zshrc file. If .zshrc doesn’t run, those tools are invisible to the terminal.

Can I launch Claude Code with Terminal.app instead of iTerm2?

Yes. Terminal.app’s do script command loads your shell profile automatically, so the script is simpler: tell application "Terminal" to do script "claude". No workaround needed.


A note from Alex: hi i’m alex - i run code for creatives. i’m a writer so i feel that it is important to say - i had claude write this piece based on my ideas and ramblings, voice notes, and teachings. the concepts were mine but the words themselves aren’t. i want to say that because its important for me to distinguish, as a writer, what is written ‘by me’ and what’s not. maybe that idea will seem insane and antiquated in a year, i’m not sure, but for now it helps me feel okay about putting stuff out there like this that a) i know is helpful and b) is not MY voice but exists within the umbrella of my business and work. If you have any thoughts or musings on this, i’d genuinely love to hear them - its an open question, all of this stuff, and my guess is as good as yours.

Ready to build this yourself?

Join the next cohort of Code for Creatives

Join the Next Cohort →