<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DockRun</title>
    <description>The latest articles on DEV Community by DockRun (@dockrun).</description>
    <link>https://dev.to/dockrun</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4263848%2F83a3b5ad-c44b-4957-ae33-7b8bf4cd5cdf.png</url>
      <title>DEV Community: DockRun</title>
      <link>https://dev.to/dockrun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dockrun"/>
    <language>en</language>
    <item>
      <title>Stop Rebuilding Your Dev Environment Every Morning: A Practical Guide to Project Launch Scripts on macOS</title>
      <dc:creator>DockRun</dc:creator>
      <pubDate>Wed, 25 Nov 2026 07:12:45 +0000</pubDate>
      <link>https://dev.to/dockrun/stop-rebuilding-your-dev-environment-every-morning-a-practical-guide-to-project-launch-scripts-on-43dc</link>
      <guid>https://dev.to/dockrun/stop-rebuilding-your-dev-environment-every-morning-a-practical-guide-to-project-launch-scripts-on-43dc</guid>
      <description>&lt;p&gt;Most of us lose the first ten minutes of a session to the same ritual: open the terminal, &lt;code&gt;cd&lt;/code&gt; into the repo, start the database, start the dev server, open the editor, open the browser on localhost, find the ticket, find the docs tab you had yesterday. Switch projects at lunch and you do it again.&lt;/p&gt;

&lt;p&gt;None of this is hard. It is just repetitive, and repetitive work is exactly what a script should own. Below is the approach I have settled on after a few iterations, starting from plain shell and moving up only when plain shell stopped being enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Write down what "ready" means
&lt;/h2&gt;

&lt;p&gt;Before automating anything, list what a project needs open for you to start working. For a typical web app it might be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Editor open on the repo root&lt;/li&gt;
&lt;li&gt;Docker services running (Postgres, Redis)&lt;/li&gt;
&lt;li&gt;Dev server running in a terminal tab&lt;/li&gt;
&lt;li&gt;Browser on &lt;code&gt;http://localhost:3000&lt;/code&gt; plus the issue tracker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you cannot write the list, the automation will not help. If the list is three items, a shell alias may be all you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: A plain zsh launcher
&lt;/h2&gt;

&lt;p&gt;macOS already ships most of what you need. &lt;code&gt;open&lt;/code&gt; launches apps, files and URLs; &lt;code&gt;code&lt;/code&gt; (or your editor's CLI) opens folders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/zsh&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; -euo pipefail

&lt;span class="nv"&gt;PROJECT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/code/shop-api
&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"$PROJECT"&lt;/span&gt;

&lt;span class="c"&gt;# Start services only if they are not already up&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; ! docker compose ps --status running &lt;span class="o"&gt;|&lt;/span&gt; grep -q postgres&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  docker compose up -d
&lt;span class="k"&gt;fi&lt;/span&gt;

code &lt;span class="s2"&gt;"$PROJECT"&lt;/span&gt;
open -a &lt;span class="s2"&gt;"Google Chrome"&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:3000"&lt;/span&gt; &lt;span class="s2"&gt;"https://linear.app/team/shop"&lt;/span&gt;

&lt;span class="c"&gt;# New Terminal window running the dev server&lt;/span&gt;
osascript -e &lt;span class="s2"&gt;"tell application \"Terminal\" to do script \"cd $PROJECT &amp;amp;&amp;amp; npm run dev\""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save it as &lt;code&gt;~/bin/shop&lt;/code&gt;, &lt;code&gt;chmod +x&lt;/code&gt; it, and you have a one-word start. A few lessons from running scripts like this daily:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Make every step idempotent.&lt;/strong&gt; You will run it twice by accident. Check before starting services; do not blindly spawn a second dev server on the same port.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;set -euo pipefail&lt;/code&gt;.&lt;/strong&gt; A silent failure halfway through leaves you with half an environment and no clue why.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not hardcode secrets.&lt;/strong&gt; Pull them from the Keychain (&lt;code&gt;security find-generic-password -s name -w&lt;/code&gt;) or a &lt;code&gt;.env&lt;/code&gt; that is gitignored.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Window placement with AppleScript
&lt;/h2&gt;

&lt;p&gt;The part that annoys people most is arranging windows afterwards. AppleScript can do it, though it is fiddly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight applescript"&gt;&lt;code&gt;&lt;span class="n"&gt;tell&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="s2"&gt;"System Events"&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;tell&lt;/span&gt; &lt;span class="n"&gt;process&lt;/span&gt; &lt;span class="s2"&gt;"Code"&lt;/span&gt;
  &lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1280&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1415&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="n"&gt;tell&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This needs Accessibility permission for whatever runs it, and hardcoded coordinates break when you switch between a laptop screen and an external monitor. If layout matters to you, read the screen size first with &lt;code&gt;osascript -e 'tell application "Finder" to get bounds of window of desktop'&lt;/code&gt; and compute halves from that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Shutting down is part of the workflow
&lt;/h2&gt;

&lt;p&gt;People automate startup and forget teardown. A matching &lt;code&gt;shop-stop&lt;/code&gt; that runs &lt;code&gt;docker compose stop&lt;/code&gt; and kills the dev server (&lt;code&gt;lsof -ti :3000 | xargs kill&lt;/code&gt;) saves battery and avoids the classic "port already in use" when you switch to another project using the same port.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Know when you have outgrown shell scripts
&lt;/h2&gt;

&lt;p&gt;The shell approach works well until:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have five or more projects and forget the script names.&lt;/li&gt;
&lt;li&gt;You want the same thing reachable from the keyboard without opening a terminal first.&lt;/li&gt;
&lt;li&gt;You want steps scheduled, or triggered from a link in your notes.&lt;/li&gt;
&lt;li&gt;Teammates or non-terminal people want to use it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that point there are several reasonable directions. Raycast and Alfred both support script commands, so you can keep your existing scripts and just give them a launcher. Hammerspoon gives you Lua and very fine control over windows if you enjoy configuring things. Keyboard Maestro is strong if your workflows involve a lot of GUI clicking.&lt;/p&gt;

&lt;p&gt;Disclosure: I am one of the people behind DockRun, a &lt;a href="https://dockrun.net" rel="noopener noreferrer"&gt;macOS command center&lt;/a&gt; that covers this specific case with "workspaces" (open a project's apps, folders and links and tile the windows in one action) and multi-step workflows that run zsh, Python, Node or AppleScript steps. It asks you to approve a script before it runs, which I mention because it is a habit worth having no matter which tool you pick. It runs locally and has a free tier, but the scripts above work fine without it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Treat scripts as code
&lt;/h2&gt;

&lt;p&gt;Whatever runner you use, keep the actual logic in plain files under version control, ideally in a &lt;code&gt;scripts/&lt;/code&gt; folder inside each repo or a dotfiles repo. That way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new teammate gets the same startup by cloning.&lt;/li&gt;
&lt;li&gt;You can review changes to anything that executes on your machine.&lt;/li&gt;
&lt;li&gt;Switching launcher tools later costs you an afternoon, not a rewrite.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The launcher is the interface; the script is the asset.&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist to steal
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;List what "ready to work" means for each project.&lt;/li&gt;
&lt;li&gt;Write an idempotent start script with strict error handling.&lt;/li&gt;
&lt;li&gt;Keep secrets out of the script.&lt;/li&gt;
&lt;li&gt;Write the matching stop script.&lt;/li&gt;
&lt;li&gt;Version-control both.&lt;/li&gt;
&lt;li&gt;Only then pick a launcher, and choose one that runs your existing scripts rather than replacing them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The goal is not a fancier setup. It is getting from lid-open to writing code without thinking about it.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foeu5oab6x820oqhc3ixj.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foeu5oab6x820oqhc3ixj.webp" alt=" " width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>macos</category>
      <category>productivity</category>
      <category>automation</category>
      <category>shell</category>
    </item>
  </channel>
</rss>
