← All examples
Terminal
Ghostty

Launch a script in a new Ghostty window

Open Ghostty in a specific project directory, run a setup script (source env vars, start a container, load credentials), then drop into an interactive shell when the script finishes.

The trick

The intuitive open -na Ghostty --args -e /bin/bash -c "./scripts/setup-env.sh; exec $SHELL -i" looks right, but it fails in two ways:

  1. Two tabs open instead of one. Ghostty's -e only consumes the next single token as the executable. Everything after that (-c, the script path, the shell line) is parsed as separate Ghostty flags, and -c triggers a second tab.
  2. command not found for Homebrew tools. Switching to --command= fixes the tab issue, but Ghostty wraps the value in bash --noprofile --norc. Your .zprofile and .zshrc never run, so /opt/homebrew/bin is missing from PATH and anything installed via Homebrew is not found.

Working configuration

{
  "label": "Open project shell (prod)",
  "type": "command",
  "command": "open",
  "args": [
    "-na", "Ghostty",
    "--args",
    "--working-directory=/Users/you/Code/your-project",
    "--command=zsh -lc './scripts/setup-env.sh prod; exec zsh -i'"
  ]
}

Paste this as an action inside any service, group, or shortcut. Replace these three placeholders with your own values:

Why this works

Prerequisites