Starting more than one dev webserver each in its own terminal window (Mac)

#!/usr/bin/env zsh
# Script to start monorepo development processes in separate terminals
open_position_run() {
  local dir=$1
  local cmd=$2

  # Start the server
  osascript -e 'tell application "Terminal"
    do script "cd '"$dir"' && nvm use 20 && '"$cmd"' &" in window 1
  end tell'
}

open_position_run "/Users/bakert/monorepo/apps/app1 "pnpm dev"
open_position_run "/Users/bakert/monorepo/apps/app2 "pnpm dev"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.