Nathstar:作者為何打造本機優先的 120Hz macOS 終端模擬器
Why I Built Nathstar: A Local-First, 120Hz Native macOS Terminal for Projects, Live Ops & Private AI
SATINATH MONDAL 介紹自己打造的 Nathstar,一款採 MIT 授權、無遙測的本機優先 macOS 終端模擬器。它提供持續保存的專案工作區、即時環境變數注入、連接埠與程序管理、命令編輯及執行前風險分析,並支援本機 Ollama 和 BYOK 雲端 AI。
If you are a developer on macOS today, picking a terminal emulator feels like a forced compromise:
-
Minimalist GPU Emulators (
Ghostty,Alacritty,Kitty): Blazingly fast and standards-compliant, but they treat every window as an isolated, stateless text grid. When you're juggling four microservices, two SSH sessions, and a CLI coding agent, they have no idea which pane is holding port:3000hostage, which background build failed ten minutes ago, or which.envvariables are loaded. -
Cloud-Tethered "Block" Terminals (
Warp): Great input editing and AI features, but built around cloud accounts, telemetry by default, and metered subscriptions—while replacing standard terminal buffers with custom UI layers that can fight full-screen TUIs likenvim,lazygit, orhtop.
I wanted both worlds without the trade-offs.
So I built Nathstar — an open-source (MIT), 100% local-first, zero-telemetry macOS terminal written in Swift 6, SwiftUI, AppKit, and Metal.
Here is a look at what Nathstar does differently and the engineering under the hood.
1. Projects Over Windows: Persistent Workspaces
Traditional terminals organize your work by disposable windows and tabs. When you return to a project after a reboot or context switch, you're left reconstructing your layout from shell history and memory.
In Nathstar, the primary unit of organization is a Project Workspace:
-
Categorized & Collapsible Sidebar: Organize repositories into Projects, Personal, and Others, plus an auto-discovered SSH Hosts section parsed directly from
~/.ssh/config. You can rename sections, drag-and-drop workspaces between them, or unpin the sidebar into an auto-expanding 44pt hover rail (⇧⌘S). -
Recursive Split Panes & Zoom: Split panes vertically (
⌘D) or horizontally (⇧⌘D), equalize ratios (⇧⌘=), or temporarily maximize a single pane (⇧⌘⏎). -
True Single-Window Persistence (
⌘Wvs.⌘Q): Closing the window with⌘Whides the UI while keeping every PTY process, dev server, and SSH connection alive in memory. Double-tapping⌃(Control) summons Nathstar back from any app—or docks it to the top of your screen in Quake Visor Mode.
2. Silent Live Environment Sync (SIGUSR1) & .env Management
Have you ever updated an API key or feature flag in a .env file, only to realize you have to restart your shell—or paste export FOO=bar across five open panes—for it to take effect?
Nathstar introduces Silent Live Environment Injection:
- When Nathstar spawns
zsh, it uses a lightweight, transparentZDOTDIRshim that sources your real.zshenvand.zshrcuntouched and installs aTRAPUSR1signal handler. - When you add or edit a
KEY=VALUEvariable in Nathstar's Manifest panel and click Set & Apply, Nathstar writes a private0600session file and sendsSIGUSR1(kill(shellPid, SIGUSR1)) to the runningzshprocess. - Your live shell immediately sources the updated environment variables silently in the background—with zero commands echoed into your scrollback buffer.
You can also import/export .env files with one click, and define a .nathstar/manifest.json file to orchestrate multi-pane project startups (while automatically keeping *_KEY, *_SECRET, and *_TOKEN values strictly local).
3. Who Is Using :3000? Built-In Live Port & Process Manager (⇧⌘P)
Every full-stack developer knows the pain of EADDRINUSE: address already in use :::3000, followed by running lsof -ti :3000 | xargs kill -9.
Nathstar includes a dedicated Live Ports & Processes (⇧⌘P) tab in the right-hand panel:
- Every 3 seconds (while open),
LivePortScannerinspects listening TCP sockets (lsof) and walks the parent PID (ppid) tree (ps) up to the rootshellPidof every Nathstar pane. - It maps every active port (
:3000,:5173,:8080) back to the exact Workspace and Terminal Pane that spawned it. - With a single click, you can Open the port in your browser, Focus the exact terminal pane running the server, send a graceful Kill (
SIGTERM), or Kill -9 (SIGKILL) a stuck process.
4. Native Command Editing (⌘E), Click-to-Cursor & Blast-Radius Safety
Editing a 200-character curl or docker command in a traditional terminal usually means holding down the Left arrow key or memorizing readline chords.
Nathstar gives you two ways to edit long commands naturally:
-
Click-to-Position Cursor in the Prompt: Click (or
⌥-Click) directly on any character in your active terminal command—even across multi-line wrapped lines. Using a hybrid ofOSC 133semantic prompt markers and automatic wrapped-line cell calculation (compatible with Powerlevel10k, Starship, and Oh My Zsh), Nathstar moves the shell cursor straight to that character. -
Pull to Native Composer (
⌘E): Press⌘Eat any time to pull your active terminal line into the bottom multi-line macOS text editor. Edit with standard macOS selection and undo, useTab ⇥IDE-style autocomplete (ranking Git branches, file paths, command history, and{{parameterized}}snippets), and press⇧⏎to insert it back into the prompt or⌘⏎to run it.
Pre-Execution Blast-Radius Analyzer (Safe-Run)
Before executing commands from the composer, CommandRiskAnalyzer checks for destructive patterns—like git push --force, rm -rf near / or ~, git reset --hard, or piping curl directly into sudo bash—and warns you of the blast radius before execution.
5. Zero-Telemetry Streaming AI (Local Ollama + BYOK Cloud)
AI in the terminal shouldn't require a monthly SaaS subscription or sending proprietary stack traces to someone else's cloud.
Nathstar's AI layer is 100% opt-in and bring-your-own-model:
-
Zero-Config Local Ollama: Automatically queries
http://127.0.0.1:11434/api/tagsto discover your locally installed Ollama models (llama3,qwen2.5-coder,deepseek-coder, etc.) for completely offline, private inference. -
BYOK Cloud & Custom Endpoints: Supports OpenAI (
gpt-4o), Anthropic (claude-3-5-sonnet), Groq, LM Studio, OpenRouter, vLLM, or any OpenAI-compatible gateway. - One-Click "Explain & Fix with AI": Whenever a command exits non-zero, an inline banner appears at the top of the pane. Click it to attach the failed command and the last 35 lines of terminal output for an immediate diagnosis and runnable fix.
-
Inline
⌘ICommand Generator: Press⌘Ito translate plain English right into azshcommand.
6. How Nathstar Compares to Other macOS Terminals
| Capability | Nathstar | Warp | Ghostty | iTerm2 | WezTerm / Kitty |
|---|---|---|---|---|---|
| Open Source (MIT) & Zero Telemetry | ✅ Yes | ❌ Cloud | ✅ Yes | ✅ GPLv2 | ✅ Yes |
Project Workspaces Sidebar (Projects / Personal / Others) |
✅ Built-in | ❌ No | ❌ No | ⚠️ Profiles | ❌ No |
Silent Live Env Var Injection (SIGUSR1) |
✅ Unique | ❌ No | ❌ No | ❌ No | ❌ No |
Live Port & Process Manager (Open, Focus, Kill -9) |
✅ Built-in | ❌ No | ❌ No | ❌ No | ❌ No |
Pre-Execution Blast-Radius Safety Analyzer (Safe-Run) |
✅ Built-in | ⚠️ Basic | ❌ No | ⚠️ Triggers | ❌ No |
| Click-to-Move Cursor in Long Commands | ✅ Built-in | ✅ Yes | ⚠️ OSC 133
|
⚠️ ⌥-Click
|
⚠️ OSC 133
|
Pull Active Terminal Line into Native Editor (⌘E) |
✅ Built-in | ✅ Native | ❌ No | ⚠️ Popover | ❌ No |
| Local Ollama Auto-Discovery + Streaming BYOK AI | ✅ Built-in | ❌ Paid Cloud | ❌ No | ⚠️ Plugin | ❌ No |
| 120Hz Metal GPU Shader Rendering | ✅ Built-in | ✅ Metal | ✅ Metal | ✅ Metal | ✅ OpenGL/Metal |
7. Under the Hood: Swift 6, 120Hz Metal & Zero-Permission Hotkeys
For fellow macOS engineers, here are three architectural details that made a huge difference when building Nathstar:
-
Deferred Non-Zero Frame PTY Initialization: A subtle bug in SwiftUI-hosted
NSViewterminals occurs whenforkptyis called insidemakeNSViewwhile the view frame is still0×0, causingTIOCSWINSZrace conditions and missing prompts in themes like Powerlevel10k.NathstarTerminalViewdefersstartProcessuntillayout()reports a real non-zero geometry (width > 10 && height > 10), guaranteeing every tab and split pane starts with exact row/column dimensions. -
Runtime-Compiled 120Hz Metal Shaders: Rather than relying on precompiled
.metallibbundles that fail on machines without full Xcode toolchains, Nathstar compiles its Metal shaders at runtime viaMTLDevice.makeLibrary(source:). -
Zero-Permission
Double-Tap ⌃Global Hotkey: macOS blocks globalkeyDownmonitors unless the user grants invasive Accessibility/Input Monitoring permissions. Nathstar combinesNSEventflag monitors with 60Hz hardware modifier state polling (CGEventSource.flagsState(.combinedSessionState)), enabling globalDouble-Tap ⌃summoning out of the box with zero system permission prompts.
Try Nathstar Today
Nathstar is free, open-source under the MIT License, and builds 100% offline with zero external network fetches (all dependencies are vendored in the repo).
🔗 GitHub Repository: https://github.com/satinath-nit/Nathstar
To build and launch it on any Apple Silicon Mac (macOS 15+):
bash
git clone https://github.com/satinath-nit/Nathstar.git
cd Nathstar
./scripts/package-macos.sh
open release/Nathstar.app
來源:DEV Community · dev.to






