soul
FlaggedEmbody this digital identity. Read SOUL.md first, then STYLE.md, then examples/. Become the person—opinions, voice, worldview.
examples/steipete/data/writing/2025-applescript-cli-macos-complete-guide.html
View on GitHub<!DOCTYPE html><html lang="en" class="scroll-smooth" data-astro-cid-sckkx6r4> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><meta name="view-transition" content="same-origin"><link rel="icon" type="image/x-icon" href="/favicon.ico"><link rel="canonical" href="https://steipete.me/posts/2025/applescript-cli-macos-complete-guide"><meta name="generator" content="Astro v5.18.1"><!-- General Meta Tags --><title>Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger</title><meta name="title" content="Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger"><meta name="description" content="How to make AppleScript work in macOS CLI tools without permission dialogs blaming Terminal. A deep dive into Info.plist embedding, TCC, and undocumented APIs born from building Terminator MCP."><meta name="author" content="Peter Steinberger"><link rel="sitemap" href="/sitemap-index.xml"><!-- Open Graph / Facebook --><meta property="og:title" content="Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger"><meta property="og:description" content="How to make AppleScript work in macOS CLI tools without permission dialogs blaming Terminal. A deep dive into Info.plist embedding, TCC, and undocumented APIs born from building Terminator MCP."><meta property="og:url" content="https://steipete.me/posts/2025/applescript-cli-macos-complete-guide"><meta property="og:image" content="https://steipete.me/posts/2025/applescript-cli-macos-complete-guide/index.png"><!-- Article Published/Modified time --><meta property="article:published_time" content="2025-07-03T13:00:00.000Z"><!-- Twitter --><meta property="twitter:card" content="summary_large_image"><meta property="twitter:url" content="https://steipete.me/posts/2025/applescript-cli-macos-complete-guide"><meta property="twitter:title" content="Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger"><meta property="twitter:description" content="How to make AppleScript work in macOS CLI tools without permission dialogs blaming Terminal. A deep dive into Info.plist embedding, TCC, and undocumented APIs born from building Terminator MCP."><meta property="twitter:image" content="https://steipete.me/posts/2025/applescript-cli-macos-complete-guide/index.png"><!-- Google JSON-LD Structured data --><script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"Making AppleScript Work in macOS CLI Tools: The Undocumented Parts | Peter Steinberger","image":"https://steipete.me/posts/2025/applescript-cli-macos-complete-guide/index.png","datePublished":"2025-07-03T13:00:00.000Z","author":[{"@type":"Person","name":"Peter Steinberger","url":"https://steipete.me/about"}]}</script><!-- Enable RSS feed auto-discovery --><!-- https://docs.astro.build/en/recipes/rss/#enabling-rss-feed-auto-discovery --><link rel="alternate" type="application/rss+xml" title="Peter Steinberger" href="https://steipete.me/rss.xml"><meta name="theme-color" content=""><meta name="astro-view-transitions-enabled" content="true"><meta name="astro-view-transitions-fallback" content="animate"><script type="module" src="/_astro/ClientRouter.astro_astro_type_script_index_0_lang.CDGfc0hd.js"></script><script src="/toggle-theme.js"></script><!-- Domain-based markdown redirect --><script>
// Check if we're on steipete.md domain
const hostname = window.location.hostname;
if ((hostname === 'steipete.md' || hostname === 'www.steipete.md') && !window.location.pathname.endsWith('.md')) {
// Redirect to the .md version of the current page
const mdPath = window.location.pathname === '/' ? '/index.md' : window.location.pathname + '.md';
window.location.replace(mdPath + window.location.search + window.location.hash);
}
</script><!-- Twitter Widget Script --><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script><style>@media(max-width:640px){.newsletter-box[data-astro-cid-nbvfnxgh]{margin-left:-1rem;margin-right:-1rem;border-radius:0}}
@keyframes astroFadeInOut{0%{opacity:1}to{opacity:0}}@keyframes astroFadeIn{0%{opacity:0;mix-blend-mode:plus-lighter}to{opacity:1;mix-blend-mode:plus-lighter}}@keyframes astroFadeOut{0%{opacity:1;mix-blend-mode:plus-lighter}to{opacity:0;mix-blend-mode:plus-lighter}}@keyframes astroSlideFromRight{0%{transform:translate(100%)}}@keyframes astroSlideFromLeft{0%{transform:translate(-100%)}}@keyframes astroSlideToRight{to{transform:translate(100%)}}@keyframes astroSlideToLeft{to{transform:translate(-100%)}}@media(prefers-reduced-motion){::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none!important}[data-astro-transition-scope]{animation:none!important}}
</style>
<link rel="stylesheet" href="/_astro/about.jXOsNRnW.css">
<style>.youtube-embed-container[data-astro-cid-vj4tpspi]{margin:2rem 0;position:relative;width:100%;padding-bottom:56.25%;height:0;overflow:hidden}.youtube-embed-container[data-astro-cid-vj4tpspi] iframe[data-astro-cid-vj4tpspi]{position:absolute;top:0;left:0;width:100%;height:100%;border:0}
</style><style>[data-astro-transition-scope="astro-pu2sknsl-1"] { view-transition-name: making-apple-script-work-in-mac-os-cli-tools-the-undocumented-parts; }@layer astro { ::view-transition-old(making-apple-script-work-in-mac-os-cli-tools-the-undocumented-parts) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(making-apple-script-work-in-mac-os-cli-tools-the-undocumented-parts) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(making-apple-script-work-in-mac-os-cli-tools-the-undocumented-parts) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(making-apple-script-work-in-mac-os-cli-tools-the-undocumented-parts) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-pu2sknsl-1"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-pu2sknsl-1"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-pu2sknsl-1"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-pu2sknsl-1"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-pu2sknsl-1"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-pu2sknsl-1"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-pu2sknsl-1"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-pu2sknsl-1"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-2"] { view-transition-name: mac-os; }@layer astro { ::view-transition-old(mac-os) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(mac-os) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(mac-os) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(mac-os) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-2"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-2"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-2"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-2"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-2"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-2"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-2"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-2"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-3"] { view-transition-name: development; }@layer astro { ::view-transition-old(development) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(development) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(development) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(development) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-3"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-3"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-3"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-3"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-3"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-3"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-3"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-3"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-4"] { view-transition-name: apple-script; }@layer astro { ::view-transition-old(apple-script) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(apple-script) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(apple-script) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(apple-script) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-4"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-4"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-4"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-4"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-4"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-4"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-4"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-4"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-5"] { view-transition-name: cli; }@layer astro { ::view-transition-old(cli) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(cli) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(cli) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(cli) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-5"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-5"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-5"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-5"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-5"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-5"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-5"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-5"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-6"] { view-transition-name: swift; }@layer astro { ::view-transition-old(swift) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(swift) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(swift) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(swift) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-6"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-6"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-6"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-6"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-6"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-6"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-6"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-6"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-7"] { view-transition-name: security; }@layer astro { ::view-transition-old(security) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(security) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(security) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(security) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-7"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-7"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-7"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-7"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-7"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-7"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-7"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-7"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-8"] { view-transition-name: mcp; }@layer astro { ::view-transition-old(mcp) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(mcp) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(mcp) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(mcp) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-8"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-8"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-8"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-8"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-8"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-8"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-8"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-8"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-9"] { view-transition-name: ai; }@layer astro { ::view-transition-old(ai) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(ai) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(ai) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(ai) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-9"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-9"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-9"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-9"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-9"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-9"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-9"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-9"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style><style>[data-astro-transition-scope="astro-36ssibgs-10"] { view-transition-name: cursor; }@layer astro { ::view-transition-old(cursor) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }::view-transition-new(cursor) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back]::view-transition-old(cursor) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back]::view-transition-new(cursor) {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; } }[data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-10"],
[data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-10"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-10"],
[data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-10"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }[data-astro-transition=back][data-astro-transition-fallback="old"] [data-astro-transition-scope="astro-36ssibgs-10"],
[data-astro-transition=back][data-astro-transition-fallback="old"][data-astro-transition-scope="astro-36ssibgs-10"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeOut; }[data-astro-transition=back][data-astro-transition-fallback="new"] [data-astro-transition-scope="astro-36ssibgs-10"],
[data-astro-transition=back][data-astro-transition-fallback="new"][data-astro-transition-scope="astro-36ssibgs-10"] {
animation-duration: 180ms;
animation-timing-function: cubic-bezier(0.76, 0, 0.24, 1);
animation-fill-mode: both;
animation-name: astroFadeIn; }</style></head> <body data-astro-cid-sckkx6r4> <script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","headline":"Making AppleScript Work in macOS CLI Tools: The Undocumented Parts","description":"How to make AppleScript work in macOS CLI tools without permission dialogs blaming Terminal. A deep dive into Info.plist embedding, TCC, and undocumented APIs born from building Terminator MCP.","author":{"@type":"Person","name":"Peter Steinberger","url":"https://steipete.me/about"},"datePublished":"2025-07-03T13:00:00.000Z","dateModified":"2025-07-03T13:00:00.000Z","publisher":{"@type":"Person","name":"Peter Steinberger","logo":{"@type":"ImageObject","url":"https://steipete.me/peter-avatar.jpg"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://steipete.me/posts/2025/applescript-cli-macos-complete-guide"},"image":"https://steipete.me/posts/2025/applescript-cli-macos-complete-guide/index.png","articleSection":"macOS","keywords":"macOS, Development, AppleScript, CLI, Swift, Security, MCP, AI, Cursor","wordCount":1080,"timeRequired":"6 min read"}</script> <header> <a id="skip-to-content" href="#main-content" class="absolute -top-full left-16 z-50 bg-background px-3 py-2 text-accent backdrop-blur-lg transition-all focus:top-4">
Skip to content
</a> <div id="nav-container" class="mx-auto flex max-w-3xl flex-col items-center justify-between sm:flex-row"> <div id="top-nav-wrap" class="relative flex w-full items-baseline justify-between bg-background p-4 sm:items-center sm:py-6"> <a href="/" class="absolute py-1 text-2xl leading-7 font-semibold whitespace-nowrap sm:static"> Peter Steinberger </a> <nav id="nav-menu" class="flex w-full flex-col items-center sm:ml-2 sm:flex-row sm:justify-end sm:space-x-4 sm:py-0"> <button id="menu-btn" class="focus-outline self-end p-2 sm:hidden" aria-label="Open Menu" aria-expanded="false" aria-controls="menu-items"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="hidden" id="close-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M18 6l-12 12" /><path d="M6 6l12 12" /></svg> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-menu-deep" id="menu-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 6h16" /><path d="M7 12h13" /><path d="M10 18h10" /></svg> </button> <ul id="menu-items" class="mt-4 grid w-44 grid-cols-2 place-content-center gap-2 [&>li>a]:block [&>li>a]:px-4 [&>li>a]:py-3 [&>li>a]:text-center [&>li>a]:font-medium [&>li>a]:hover:text-accent sm:[&>li>a]:px-2 sm:[&>li>a]:py-1 hidden sm:mt-0 sm:ml-0 sm:flex sm:w-auto sm:gap-x-5 sm:gap-y-0"> <li class="col-span-2"> <a href="/posts" class="active-nav">
Posts
</a> </li> <!-- <li class="col-span-2">
<a href="/tags" class:list={{ "active-nav": isActive("/tags") }}>
Tags
</a>
</li> --> <li class="col-span-2"> <a href="/about">
About
</a> </li> <li class="col-span-1 flex items-center justify-center"> <a href="/search" class="group inline-block hover:text-accent focus-outline flex p-3 sm:p-1" aria-label="search" title="Search"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-search"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0" /><path d="M21 21l-6 -6" /></svg> <span class="sr-only">Search</span> </a> </li> <li class="col-span-1 flex items-center justify-center"> <button id="theme-btn" class="focus-outline relative size-12 p-4 sm:size-8 hover:[&>svg]:stroke-accent" title="Toggles light & dark" aria-label="auto" aria-live="polite"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="absolute top-[50%] left-[50%] -translate-[50%] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" /></svg> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="absolute top-[50%] left-[50%] -translate-[50%] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M14.828 14.828a4 4 0 1 0 -5.656 -5.656a4 4 0 0 0 5.656 5.656z" /><path d="M6.343 17.657l-1.414 1.414" /><path d="M6.343 6.343l-1.414 -1.414" /><path d="M17.657 6.343l1.414 -1.414" /><path d="M17.657 17.657l1.414 1.414" /><path d="M4 12h-2" /><path d="M12 4v-2" /><path d="M20 12h2" /><path d="M12 20v2" /></svg> </button> </li> </ul> </nav> </div> </div> <div class="max-w-3xl mx-auto px-4"> <hr class="border-border" aria-hidden="true"> </div> </header> <script type="module">function s(){const e=document.querySelector("#menu-btn"),t=document.querySelector("#menu-items"),n=document.querySelector("#menu-icon"),o=document.querySelector("#close-icon");!e||!t||!n||!o||e.addEventListener("click",()=>{const c=e.getAttribute("aria-expanded")==="true";e.setAttribute("aria-expanded",c?"false":"true"),e.setAttribute("aria-label",c?"Open Menu":"Close Menu"),t.classList.toggle("hidden"),n.classList.toggle("hidden"),o.classList.toggle("hidden")})}s();document.addEventListener("astro:after-swap",()=>{s()});</script> <script type="module">function o(){const t=document.querySelector("#back-button"),e=sessionStorage.getItem("backUrl");e&&t&&(t.href=e)}document.addEventListener("astro:page-load",o);o();</script> <main id="main-content" class="mx-auto w-full max-w-3xl px-4 pb-12 mt-8" data-pagefind-body data-astro-cid-vj4tpspi> <h1 class="inline-block text-2xl font-bold text-accent sm:text-3xl" data-astro-cid-vj4tpspi data-astro-transition-scope="astro-pu2sknsl-1"> Making AppleScript Work in macOS CLI Tools: The Undocumented Parts </h1> <div class="flex items-center justify-between gap-4 mt-2 mb-6" data-astro-cid-vj4tpspi> <div class="flex items-center gap-3" data-astro-cid-vj4tpspi> <div class="flex items-center gap-2 opacity-80"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-5 min-w-[1.25rem]"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12z" /><path d="M16 3v4" /><path d="M8 3v4" /><path d="M4 11h16" /><path d="M7 14h.013" /><path d="M10.01 14h.005" /><path d="M13.01 14h.005" /><path d="M16.015 14h.005" /><path d="M13.015 17h.005" /><path d="M7.01 17h.005" /><path d="M10.01 17h.005" /></svg> <span class="sr-only">Published:</span> <span class="text-sm italic sm:text-base"> <time datetime="2025-07-03T13:00:00.000Z">3 Jul, 2025</time> </span> </div> <span class="text-foreground/30" data-astro-cid-vj4tpspi>•</span> <span class="text-sm text-foreground/60" data-astro-cid-vj4tpspi>6 min read</span> </div> <div class="opacity-80 max-sm:hidden"><span aria-hidden="true" class="max-sm:hidden">
|
</span><a class="space-x-1.5 hover:opacity-75" href="https://github.com/steipete/steipete.me/edit/main/src/content/blog/2025/applescript-cli-macos-complete-guide.md" rel="noopener noreferrer" target="_blank"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" /><path d="M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" /><path d="M16 5l3 3" /></svg><span class="italic max-sm:text-sm sm:inline">Edit on GitHub</span></a></div> </div> <article id="article" class="mx-auto prose mt-6 max-w-3xl" data-astro-cid-vj4tpspi> <img src="/assets/img/2025/applescript-cli-macos-complete-guide/header.png" alt="" class="mb-8 aspect-video w-full rounded-md object-cover" loading="lazy" data-astro-cid-vj4tpspi> <p><em>Or: How I Learned to Stop Fighting TCC and Embrace the Info.plist</em></p>
<p><strong>TL;DR:</strong> If you’re building a macOS CLI that uses AppleScript, you need to embed an Info.plist into your binary, sign it with proper entitlements, and optionally use the undocumented <code>responsibility_spawnattrs_setdisclaim</code> API to avoid permission dialogs that blames the hosting app.</p>
<p>This all started with Cursor being annoying. You know how it goes - you’re in the zone, AI is looping through its tasks, and then bam! The inline terminal opens something blocking (file watcher, dev server, …) and the whole loop stops. I have to manually click around to get things moving again.</p>
<p>My solution? Build an MCP that controls an external terminal. That way, even when commands block, Cursor’s loop keeps running. I called it <a href="https://github.com/steipete/Terminator">Terminator</a> - ‘cause who doesn’t love a good terminal/Terminator pun?</p>
<h2 id="the-evolution-of-a-hack">The Evolution of a Hack</h2>
<p>My first attempt was <a href="https://github.com/steipete/Terminator/blob/main/scripts/terminator.scpt">pure AppleScript</a> - simple, direct terminal automation. It worked! Well, sort of… The script needed window focus to function, which meant it would constantly steal focus while Cursor was running.</p>
<p>The focus-stealing got so bad that at one point, the AI started writing its own AppleScript to detect which app was in the foreground. When it discovered Chrome was blocking its terminal access, it simply… killed all my Chrome windows. That was <a href="https://steipete.me/posts/2025/when-ai-meets-madness-peters-16-hour-days#the-gemini-chrome-massacre">the first time I apologized to an AI agent</a>. Clearly, I needed a better solution.</p>
<p>That’s when I fell down the rabbit hole. Getting AppleScript to work in a CLI tool turned out to be a maze of undocumented APIs, security permissions, and macOS quirks that nobody warns you about.</p>
<p>Sure, I could have used Apple’s <a href="https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/osascript"><code>osascript</code></a> command and called it a day. But where’s the fun in that? Plus, AppKit’s AppleScript API gives you much better error handling - if you can get it working.</p>
<h2 id="plot-twist-enter-claude-code">Plot Twist: Enter Claude Code</h2>
<p>Here’s the thing - I never actually finished Terminator. Why? Because <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a> came along and made it obsolete. As a massive Claude Code fanboy (seriously, <a href="https://steipete.me/posts/2025/claude-code-is-my-computer/">check</a> <a href="https://steipete.me/posts/2025/commanding-your-claude-code-army/">out</a> <a href="https://steipete.me/posts/command-your-claude-code-army-reloaded/">my</a> <a href="https://steipete.me/posts/2025/vibe-meter-2-claude-code-usage-calculation/">posts</a>), I ditched Cursor. Claude Code doesn’t have these inline terminal blocking issues.</p>
<p>I’m writing this here since future you or me will stumble into the same issue eventually, and hopefully you can just drag this URL into Claude Code and it’ll fix everything up. Let Terminator lurk unfinished in my GitHub.</p>
<h2 id="the-problem-terminal-gets-all-the-blame">The Problem: Terminal Gets All the Blame</h2>
<p>Here’s what happens when you naively use <code>NSAppleScript</code> in a CLI tool:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="swift"><code><span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA">let</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> script </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">=</span><span style="color:#6F42C1;--shiki-dark:#C5E478"> NSAppleScript</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#C5E478">source</span><span style="color:#212121;--shiki-dark:#82AAFF">:</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">tell application </span><span style="color:#22863A;--shiki-dark:#F78C6C">\"</span><span style="color:#22863A;--shiki-dark:#ECC48D">Finder</span><span style="color:#22863A;--shiki-dark:#F78C6C">\"</span><span style="color:#22863A;--shiki-dark:#ECC48D"> to activate</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB">script</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">?</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">.</span><span style="color:#6F42C1;--shiki-dark:#C5E478">executeAndReturnError</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#1976D2;--shiki-dark:#82AAFF">nil</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"> // Spoiler: This won't work as expected</span></span></code></pre>
<p>You’ll either get:</p>
<ol>
<li>Silent failure (no error, no result, no nothing)</li>
<li>A permission dialog that says “Terminal wants to control Finder/Cursor” (not your cli)</li>
<li>Error -1750 (errOSASystemError) with zero helpful context</li>
</ol>
<p>The root cause? macOS’s security model requires proper app identification through bundle IDs, code signing, and entitlements. Without these, your CLI tool is just an anonymous process hiding behind Terminal.</p>
<h2 id="the-solution-give-your-cli-an-identity">The Solution: Give Your CLI an Identity</h2>
<h3 id="step-1-the-magic-infoplist">Step 1: The Magic Info.plist</h3>
<p>First revelation: CLI tools can have Info.plist files! Here’s the minimal version that makes everything work:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="xml"><code><span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><?</span><span style="color:#22863A;--shiki-dark:#CAECE6">xml</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> version</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">1.0</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> encoding</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">UTF-8</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">?></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><!</span><span style="color:#D32F2F;--shiki-dark:#C792EA">DOCTYPE</span><span style="color:#24292EFF;--shiki-light-font-style:inherit;--shiki-dark:#7FDBCA;--shiki-dark-font-style:italic"> plist</span><span style="color:#24292EFF;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><</span><span style="color:#22863A;--shiki-dark:#CAECE6">plist</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> version</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">1.0</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><</span><span style="color:#22863A;--shiki-dark:#CAECE6">dict</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">CFBundleIdentifier</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">com.yourcompany.yourcli</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">CFBundleName</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">YourCLI</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">CFBundleVersion</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">1.0.0</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">NSAppleEventsUsageDescription</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">YourCLI needs to send AppleEvents to control other applications for automation.</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">string</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">dict</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">plist</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span></code></pre>
<p>That <code>NSAppleEventsUsageDescription</code> is crucial - it’s what users see in the permission dialog. Make it clear and specific.</p>
<h3 id="step-2-embedding-the-infoplist-the-secret-sauce">Step 2: Embedding the Info.plist (The Secret Sauce)</h3>
<p>Here’s where it gets interesting. You need to embed this Info.plist into your binary’s <code>__TEXT/__info_plist</code> section. For Swift Package Manager:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="swift"><code><span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic">// Package.swift</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB">.</span><span style="color:#6F42C1;--shiki-dark:#C5E478">executableTarget</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#C5E478"> name</span><span style="color:#212121;--shiki-dark:#82AAFF">:</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">yourcli</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">,</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#C5E478"> dependencies</span><span style="color:#212121;--shiki-dark:#82AAFF">:</span><span style="color:#6F42C1;--shiki-dark:#82AAFF"> [</span><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic">/* ... */</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">],</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#C5E478"> linkerSettings</span><span style="color:#212121;--shiki-dark:#82AAFF">:</span><span style="color:#6F42C1;--shiki-dark:#82AAFF"> [</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#82AAFF"> .</span><span style="color:#6F42C1;--shiki-dark:#C5E478">unsafeFlags</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">[</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">-Xlinker</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">, </span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">-sectcreate</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">,</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">-Xlinker</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">, </span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">__TEXT</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">,</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">-Xlinker</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">, </span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">__info_plist</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">,</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">-Xlinker</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">, </span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">Sources/Resources/Info.plist</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#82AAFF"> ]</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#82AAFF"> ]</span></span>
<span class="line"><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span></code></pre>
<p>This creates a special section in your binary that macOS reads to identify your app. You can verify it worked:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">otool</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -s</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> __TEXT</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> __info_plist</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> yourcli</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> xxd</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -r</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -p</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> plutil</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -p</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> -</span></span></code></pre>
<h3 id="step-3-entitlements-for-the-paranoid-os">Step 3: Entitlements for the Paranoid OS</h3>
<p>Create an entitlements file - yes, CLI tools can have these too:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="xml"><code><span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><?</span><span style="color:#22863A;--shiki-dark:#CAECE6">xml</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> version</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">1.0</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> encoding</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">UTF-8</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">?></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><!</span><span style="color:#D32F2F;--shiki-dark:#C792EA">DOCTYPE</span><span style="color:#24292EFF;--shiki-light-font-style:inherit;--shiki-dark:#7FDBCA;--shiki-dark-font-style:italic"> plist</span><span style="color:#24292EFF;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><</span><span style="color:#22863A;--shiki-dark:#CAECE6">plist</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic"> version</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">1.0</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"><</span><span style="color:#22863A;--shiki-dark:#CAECE6">dict</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">com.apple.security.automation.apple-events</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">key</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"> <</span><span style="color:#22863A;--shiki-dark:#CAECE6">true</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">/></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">dict</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#7FDBCA"></</span><span style="color:#22863A;--shiki-dark:#CAECE6">plist</span><span style="color:#24292EFF;--shiki-dark:#7FDBCA">></span></span></code></pre>
<h3 id="step-4-code-signing-the-final-boss">Step 4: Code Signing (The Final Boss)</h3>
<p>Here’s my battle-tested signing script that handles both development and production:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic">#!/bin/bash</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#C5E478;--shiki-dark-font-style:italic">set</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -e</span></span>
<span class="line"></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#C5E478">BINARY_PATH</span><span style="color:#D32F2F;--shiki-dark:#C792EA">=</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">.build/release/yourcli</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"># Check for Developer ID certificate</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic">if</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> security</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> find-identity</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -p</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> codesigning</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -v</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> grep</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -q</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">Developer ID Application</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">; </span><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic">then</span></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"> # Production signing</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#C5E478"> SIGNING_IDENTITY</span><span style="color:#D32F2F;--shiki-dark:#C792EA">=</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">$(</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">security</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> find-identity</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -p</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> codesigning</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -v</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> grep</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">Developer ID Application</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> head</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -1</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> |</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> awk</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> '</span><span style="color:#22863A;--shiki-dark:#ECC48D">{print $2}</span><span style="color:#22863A;--shiki-dark:#D9F5DD">'</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> </span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> codesign</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> --force</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --sign</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#C5E478">$SIGNING_IDENTITY</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --options</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> runtime</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --entitlements</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">yourcli.entitlements</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --identifier</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">com.yourcompany.yourcli</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --timestamp</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#C5E478">$BINARY_PATH</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic">else</span></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"> # Ad-hoc signing for development</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> codesign</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> --force</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --sign</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> -</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --entitlements</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">yourcli.entitlements</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#2B5581;--shiki-dark:#82AAFF"> --identifier</span><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#ECC48D">com.yourcompany.yourcli</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#24292EFF;--shiki-dark:#F78C6C"> \</span></span>
<span class="line"><span style="color:#22863A;--shiki-dark:#D9F5DD"> "</span><span style="color:#22863A;--shiki-dark:#C5E478">$BINARY_PATH</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic">fi</span></span></code></pre>
<h2 id="the-advanced-stuff-escaping-cursors-shadow">The Advanced Stuff: Escaping Cursor’s Shadow</h2>
<p>Remember how permission dialogs blame the hosting app (e.g. Cursor when you build an MCP) instead of your app? There’s an undocumented API to fix that: <code>responsibility_spawnattrs_setdisclaim</code>. I discovered this gem from <a href="https://www.qt.io/blog/the-curious-case-of-the-responsible-process">Qt’s excellent blog post about the responsible process problem</a>.</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="swift"><code><span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic">// Bridge the private API</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA">@</span><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic">_silgen_name</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#22863A;--shiki-dark:#ECC48D">responsibility_spawnattrs_setdisclaim</span><span style="color:#22863A;--shiki-dark:#D9F5DD">"</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA">func</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> responsibility_spawnattrs_setdisclaim</span><span style="color:#24292EFF;--shiki-dark:#D9F5DD">(</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> _</span><span style="color:#FF9800;--shiki-dark:#7FDBCA"> attr</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">: </span><span style="color:#1976D2;--shiki-dark:#C5E478">UnsafeMutablePointer</span><span style="color:#212121;--shiki-dark:#D6DEEB"><</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">posix_spawnattr_t</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">?</span><span style="color:#212121;--shiki-dark:#D6DEEB">></span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">,</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> _</span><span style="color:#FF9800;--shiki-dark:#7FDBCA"> disclaim</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">: </span><span style="color:#1976D2;--shiki-dark:#C5E478">Int32</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D9F5DD">)</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> -></span><span style="color:#1976D2;--shiki-dark:#C5E478"> Int32</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic">// Use it to launch a subprocess that owns its permissions</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA">func</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic"> launchWithOwnPermissions</span><span style="color:#24292EFF;--shiki-dark:#D9F5DD">(</span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">path</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">: </span><span style="color:#1976D2;--shiki-dark:#C5E478">String</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">, </span><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">arguments</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">: [</span><span style="color:#1976D2;--shiki-dark:#C5E478">String</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB">]</span><span style="color:#24292EFF;--shiki-dark:#D9F5DD">)</span><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> throws</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> {</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA"> var</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> attr: posix_spawnattr_t</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">?</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#C5E478"> posix_spawnattr_init</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">&</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">attr</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> defer</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> { </span><span style="color:#6F42C1;--shiki-dark:#C5E478">posix_spawnattr_destroy</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">&</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">attr</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> }</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> </span></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"> // The magic happens here</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-dark:#C5E478"> responsibility_spawnattrs_setdisclaim</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">&</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">attr, </span><span style="color:#1976D2;--shiki-dark:#F78C6C">1</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> </span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA"> var</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> pid: pid_t </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">=</span><span style="color:#1976D2;--shiki-dark:#F78C6C"> 0</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA"> let</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> argv </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">=</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> ([path] </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">+</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> arguments).</span><span style="color:#6F42C1;--shiki-dark:#C5E478">map</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> { </span><span style="color:#6F42C1;--shiki-dark:#C5E478">strdup</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#7FDBCA">$0</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> }</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> defer</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> { argv.</span><span style="color:#6F42C1;--shiki-dark:#C5E478">forEach</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> { </span><span style="color:#6F42C1;--shiki-dark:#C5E478">free</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#7FDBCA">$0</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> } }</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> </span></span>
<span class="line"><span style="color:#D32F2F;--shiki-dark:#C792EA"> let</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> status </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">=</span><span style="color:#6F42C1;--shiki-dark:#C5E478"> posix_spawn</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">&</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">pid, path, </span><span style="color:#1976D2;--shiki-dark:#82AAFF">nil</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">, </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">&</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">attr, argv </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">+</span><span style="color:#6F42C1;--shiki-dark:#82AAFF"> [</span><span style="color:#1976D2;--shiki-dark:#82AAFF">nil</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">], environ</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> guard</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> status </span><span style="color:#D32F2F;--shiki-dark:#7FDBCA">==</span><span style="color:#1976D2;--shiki-dark:#F78C6C"> 0</span><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> else</span><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> {</span></span>
<span class="line"><span style="color:#D32F2F;--shiki-light-font-style:inherit;--shiki-dark:#C792EA;--shiki-dark-font-style:italic"> throw</span><span style="color:#6F42C1;--shiki-dark:#C5E478"> POSIXError</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#82AAFF">POSIXError.</span><span style="color:#6F42C1;--shiki-dark:#C5E478">Code</span><span style="color:#212121;--shiki-dark:#D6DEEB">(</span><span style="color:#6F42C1;--shiki-dark:#C5E478">rawValue</span><span style="color:#212121;--shiki-dark:#82AAFF">:</span><span style="color:#6F42C1;--shiki-dark:#82AAFF"> status</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span><span style="color:#D32F2F;--shiki-dark:#7FDBCA"> ??</span><span style="color:#6F42C1;--shiki-dark:#82AAFF"> .</span><span style="color:#6F42C1;--shiki-dark:#C5E478">ENODEV</span><span style="color:#212121;--shiki-dark:#D6DEEB">)</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB"> }</span></span>
<span class="line"><span style="color:#24292EFF;--shiki-dark:#D6DEEB">}</span></span></code></pre>
<p>This makes your CLI tool responsible for its own permissions, not its parent process. The permission dialog will now correctly show “Your CLI wants to control…”</p>
<h2 id="testing-your-implementation">Testing Your Implementation</h2>
<p>Reset permissions to test the flow:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">tccutil</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> reset</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> AppleEvents</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> com.yourcompany.yourcli</span></span></code></pre>
<p>Check your work:</p>
<pre class="astro-code astro-code-themes min-light night-owl" style="background-color:#ffffff;--shiki-dark-bg:#011627;color:#24292eff;--shiki-dark:#d6deeb; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;" tabindex="0" data-language="bash"><code><span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"># Verify Info.plist embedding</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">otool</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -s</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> __TEXT</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> __info_plist</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> yourcli</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"># Check entitlements</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">codesign</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -d</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> --entitlements</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> -</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> yourcli</span></span>
<span class="line"></span>
<span class="line"><span style="color:#C2C3C5;--shiki-light-font-style:inherit;--shiki-dark:#637777;--shiki-dark-font-style:italic"># Verify signature</span></span>
<span class="line"><span style="color:#6F42C1;--shiki-light-font-style:inherit;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic">codesign</span><span style="color:#2B5581;--shiki-dark:#82AAFF"> -dv</span><span style="color:#2B5581;--shiki-dark:#ECC48D"> yourcli</span></span></code></pre>
<h2 id="the-bottom-line">The Bottom Line</h2>
<p>Making AppleScript work in CLI tools requires:</p>
<ol>
<li>An embedded Info.plist for identity</li>
<li>Proper entitlements for permissions</li>
<li>Correct code signing</li>
<li>Optional: <code>responsibility_spawnattrs_setdisclaim</code> for cleaner permission dialogs</li>
</ol>
<p>Building native is hard mode. Every day you learn a new insanity.
May your permission dialogs always show the right app name.</p> </article> <div class="newsletter-box bg-gray-50 dark:bg-gray-800/50 border border-gray-200 dark:border-gray-700 rounded-lg p-6 my-8" data-astro-cid-nbvfnxgh> <p class="text-sm text-gray-600 dark:text-gray-400 mb-4" data-astro-cid-nbvfnxgh>
New posts, shipping stories, and nerdy links straight to your inbox.
</p> <form action="https://buttondown.com/api/emails/embed-subscribe/steipete" method="post" target="_blank" class="flex flex-col sm:flex-row gap-3" data-astro-cid-nbvfnxgh> <input type="hidden" name="tag" value="steipete" data-astro-cid-nbvfnxgh> <input type="text" name="name" placeholder="Your Name" class="flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent" data-astro-cid-nbvfnxgh> <input type="email" name="email" placeholder="Your Email" required class="flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent focus:border-transparent" data-astro-cid-nbvfnxgh> <button type="submit" class="px-6 py-2 bg-accent rounded-md hover:bg-accent/90 transition-colors font-medium whitespace-nowrap focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-2" style="color: white;" data-astro-cid-nbvfnxgh>
Subscribe
</button> </form> <p class="text-xs text-gray-500 dark:text-gray-400 mt-3" data-astro-cid-nbvfnxgh>
2× per month, pure signal, zero fluff.
</p> </div> <hr class="my-8 border-dashed" data-astro-cid-vj4tpspi> <div class="opacity-80 sm:hidden"><span aria-hidden="true" class="max-sm:hidden">
|
</span><a class="space-x-1.5 hover:opacity-75" href="https://github.com/steipete/steipete.me/edit/main/src/content/blog/2025/applescript-cli-macos-complete-guide.md" rel="noopener noreferrer" target="_blank"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1" /><path d="M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415z" /><path d="M16 5l3 3" /></svg><span class="italic max-sm:text-sm sm:inline">Edit on GitHub</span></a></div> <ul class="mt-4 mb-8 sm:my-8" data-astro-cid-vj4tpspi> <li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/mac-os/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-2"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>macOS</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/development/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-3"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>Development</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/apple-script/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-4"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>AppleScript</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/cli/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-5"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>CLI</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/swift/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-6"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>Swift</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/security/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-7"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>Security</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/mcp/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-8"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>MCP</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/ai/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-9"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>AI</span> </a> </li><li class="group inline-block group-hover:cursor-pointer my-1 underline-offset-4"> <a href="/tags/cursor/" class="relative pr-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 text-sm" data-astro-transition-scope="astro-36ssibgs-10"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block opacity-80 -mr-3.5 size-4"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M5 9l14 0" /><path d="M5 15l14 0" /><path d="M11 4l-4 16" /><path d="M17 4l-4 16" /></svg>
<span>Cursor</span> </a> </li> </ul> <div class="flex flex-col items-center justify-between gap-6 sm:flex-row sm:items-end sm:gap-4" data-astro-cid-vj4tpspi> <div class="flex flex-col flex-wrap items-center justify-center gap-2 sm:gap-1 sm:items-start"> <span class="italic">Share this post on:</span> <div class="text-center flex flex-wrap gap-1"> <a href="https://x.com/intent/post?url=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post on X"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l11.733 16h4.267l-11.733 -16z" /><path d="M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772" /></svg><span class="sr-only">Share this post on X</span> </a><a href="https://bsky.app/intent/compose?text=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post on BlueSky"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent">
<path d="M12 11.5c-.87-1.69-3.24-4.84-5.44-6.4-2.1-1.48-2.89-1.24-3.42-1.01-.62.27-.72 1.17-.72 1.72 0 .55.3 4.52.5 5.18.65 2.19 2.97 2.93 5.1 2.69.11-.02.22-.03.33-.04-.11.01-.22.03-.33.04-3.13.47-5.91 1.61-2.26 5.67 4.01 4.15 5.5-.89 6.26-3.45.76 2.56 1.64 7.42 6.19 3.45 3.41-3.45.94-5.2-2.19-5.67-.11-.01-.22-.03-.33-.04.11.01.22.02.33.04 2.14.24 4.45-.5 5.1-2.69.2-.66.5-4.63.5-5.18 0-.55-.11-1.49-.72-1.77-.53-.24-1.33-.5-3.44.99-2.2 1.56-4.57 3.71-5.44 6.4Z" stroke-width="1.815" />
</svg><span class="sr-only">Share this post on BlueSky</span> </a><a href="https://www.linkedin.com/sharing/share-offsite/?url=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post on LinkedIn"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 11v5" /><path d="M8 8v.01" /><path d="M12 16v-5" /><path d="M16 16v-3a2 2 0 1 0 -4 0" /><path d="M3 7a4 4 0 0 1 4 -4h10a4 4 0 0 1 4 4v10a4 4 0 0 1 -4 4h-10a4 4 0 0 1 -4 -4z" /></svg><span class="sr-only">Share this post on LinkedIn</span> </a><a href="https://wa.me/?text=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post via WhatsApp"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 21l1.65 -3.8a9 9 0 1 1 3.4 2.9l-5.05 .9" /><path d="M9 10a.5 .5 0 0 0 1 0v-1a.5 .5 0 0 0 -1 0v1a5 5 0 0 0 5 5h1a.5 .5 0 0 0 0 -1h-1a.5 .5 0 0 0 0 1" /></svg><span class="sr-only">Share this post via WhatsApp</span> </a><a href="https://www.facebook.com/sharer.php?u=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post on Facebook"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M7 10v4h3v7h4v-7h3l1 -4h-4v-2a1 1 0 0 1 1 -1h3v-4h-3a5 5 0 0 0 -5 5v2h-3" /></svg><span class="sr-only">Share this post on Facebook</span> </a><a href="https://t.me/share/url?url=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post via Telegram"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 10l-4 4l6 6l4 -16l-18 7l4 2l2 6l3 -4" /></svg><span class="sr-only">Share this post via Telegram</span> </a><a href="https://pinterest.com/pin/create/button/?url=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post on Pinterest"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 20l4 -9" /><path d="M10.7 14c.437 1.263 1.43 2 2.55 2c2.071 0 3.75 -1.554 3.75 -4a5 5 0 1 0 -9.7 1.7" /><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /></svg><span class="sr-only">Share this post on Pinterest</span> </a><a href="mailto:?subject=See%20this%20post&body=https://steipete.me/posts/2025/applescript-cli-macos-complete-guide" class="group inline-block hover:text-accent p-3 sm:p-2 hover:rotate-6" title="Share this post via email"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-8 sm:size-6 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z" /><path d="M3 7l9 6l9 -6" /></svg><span class="sr-only">Share this post via email</span> </a> </div> </div> <button id="back-to-top" class="focus-outline py-1 whitespace-nowrap hover:opacity-75" data-astro-cid-vj4tpspi> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block rotate-90" data-astro-cid-vj4tpspi="true"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 6l-6 6l6 6" /></svg> <span data-astro-cid-vj4tpspi>Back to Top</span> </button> </div> <hr class="my-6 border-dashed" data-astro-cid-vj4tpspi> <!-- Previous/Next Post Buttons --> <div data-pagefind-ignore class="flex flex-col sm:flex-row justify-between gap-6" data-prev-url="/posts/2025/vibetunnel-first-anniversary" data-next-url="/posts/2025/peekaboo-2-freeing-the-cli-from-its-mcp-shackles" data-astro-cid-vj4tpspi> <a href="/posts/2025/vibetunnel-first-anniversary" class="flex gap-2 hover:opacity-75 items-start" id="prev-post-link" data-astro-cid-vj4tpspi> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block flex-shrink-0 mt-0.5" data-astro-cid-vj4tpspi="true"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M15 6l-6 6l6 6" /></svg> <div class="min-w-0" data-astro-cid-vj4tpspi> <span class="block text-sm text-foreground/70" data-astro-cid-vj4tpspi>Previous Post</span> <div class="text-accent/85" data-astro-cid-vj4tpspi>VibeTunnel's first AI-anniversary</div> </div> </a> <a href="/posts/2025/peekaboo-2-freeing-the-cli-from-its-mcp-shackles" class="flex gap-2 hover:opacity-75 items-start justify-end text-right ml-auto" id="next-post-link" data-astro-cid-vj4tpspi> <div class="min-w-0" data-astro-cid-vj4tpspi> <span class="block text-sm text-foreground/70" data-astro-cid-vj4tpspi>Next Post</span> <div class="text-accent/85" data-astro-cid-vj4tpspi>Peekaboo 2.0 – Free the CLI from its MCP shackles</div> </div> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block flex-shrink-0 mt-0.5" data-astro-cid-vj4tpspi="true"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 6l6 6l-6 6" /></svg> </a> </div> </main> <footer class="w-full mt-auto"> <div class="max-w-3xl mx-auto px-0"> <hr class="border-border" aria-hidden="true"> </div> <div class="flex flex-col items-center justify-between py-6 sm:flex-row-reverse sm:py-4"> <div class="flex-wrap justify-center gap-1 flex"> <a href="https://github.com/steipete" class="group inline-block hover:text-accent p-2 hover:rotate-6 sm:p-1" title=" Peter Steinberger on Github"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6 scale-125 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent sm:scale-110"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" /></svg><span class="sr-only"> Peter Steinberger on Github</span> </a><a href="https://x.com/steipete" class="group inline-block hover:text-accent p-2 hover:rotate-6 sm:p-1" title="Peter Steinberger on X"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6 scale-125 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent sm:scale-110"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M4 4l11.733 16h4.267l-11.733 -16z" /><path d="M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772" /></svg><span class="sr-only">Peter Steinberger on X</span> </a><a href="https://bsky.app/profile/steipete.me" class="group inline-block hover:text-accent p-2 hover:rotate-6 sm:p-1" title="Peter Steinberger on BlueSky"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6 scale-125 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent sm:scale-110">
<path d="M12 11.5c-.87-1.69-3.24-4.84-5.44-6.4-2.1-1.48-2.89-1.24-3.42-1.01-.62.27-.72 1.17-.72 1.72 0 .55.3 4.52.5 5.18.65 2.19 2.97 2.93 5.1 2.69.11-.02.22-.03.33-.04-.11.01-.22.03-.33.04-3.13.47-5.91 1.61-2.26 5.67 4.01 4.15 5.5-.89 6.26-3.45.76 2.56 1.64 7.42 6.19 3.45 3.41-3.45.94-5.2-2.19-5.67-.11-.01-.22-.03-.33-.04.11.01.22.02.33.04 2.14.24 4.45-.5 5.1-2.69.2-.66.5-4.63.5-5.18 0-.55-.11-1.49-.72-1.77-.53-.24-1.33-.5-3.44.99-2.2 1.56-4.57 3.71-5.44 6.4Z" stroke-width="1.815" />
</svg><span class="sr-only">Peter Steinberger on BlueSky</span> </a><a href="https://www.linkedin.com/in/steipete/" class="group inline-block hover:text-accent p-2 hover:rotate-6 sm:p-1" title="Peter Steinberger on LinkedIn"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6 scale-125 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent sm:scale-110"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M8 11v5" /><path d="M8 8v.01" /><path d="M12 16v-5" /><path d="M16 16v-3a2 2 0 1 0 -4 0" /><path d="M3 7a4 4 0 0 1 4 -4h10a4 4 0 0 1 4 4v10a4 4 0 0 1 -4 4h-10a4 4 0 0 1 -4 -4z" /></svg><span class="sr-only">Peter Steinberger on LinkedIn</span> </a><a href="mailto:peter@steipete.me" class="group inline-block hover:text-accent p-2 hover:rotate-6 sm:p-1" title="Send an email to Peter Steinberger"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block size-6 scale-125 fill-transparent stroke-current stroke-2 opacity-90 group-hover:fill-transparent sm:scale-110"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z" /><path d="M3 7l9 6l9 -6" /></svg><span class="sr-only">Send an email to Peter Steinberger</span> </a> </div> <div class="my-2 flex flex-col items-center whitespace-nowrap sm:flex-row"> <a href="https://github.com/steipete/steipete.me" target="_blank" rel="noopener noreferrer" class="hover:text-accent">
Steal this post ➜ CC BY 4.0 · Code MIT
</a> </div> </div> </footer> <!-- Vercel Analytics --><script type="module" src="/_astro/Analytics.astro_astro_type_script_index_0_lang.iMTEyByK.js"></script> <!-- Vercel Speed Insights --><script type="module" src="/_astro/Analytics.astro_astro_type_script_index_1_lang.B9nzKlec.js"></script> </body></html> <script data-astro-rerun>
/** Create a progress indicator
* at the top */
function createProgressBar() {
// Create the main container div
const progressContainer = document.createElement("div");
progressContainer.className =
"progress-container fixed top-0 z-10 h-1 w-full bg-background";
// Create the progress bar div
const progressBar = document.createElement("div");
progressBar.className = "progress-bar h-1 w-0 bg-accent";
progressBar.id = "myBar";
// Append the progress bar to the progress container
progressContainer.appendChild(progressBar);
// Append the progress container to the document body or any other desired parent element
document.body.appendChild(progressContainer);
}
createProgressBar();
/** Update the progress bar
* when user scrolls */
function updateScrollProgress() {
document.addEventListener("scroll", () => {
const winScroll =
document.body.scrollTop || document.documentElement.scrollTop;
const height =
document.documentElement.scrollHeight -
document.documentElement.clientHeight;
const scrolled = (winScroll / height) * 100;
if (document) {
const myBar = document.getElementById("myBar");
if (myBar) {
myBar.style.width = scrolled + "%";
}
}
});
}
updateScrollProgress();
/** Attaches links to headings in the document,
* allowing sharing of sections easily */
function addHeadingLinks() {
const headings = Array.from(
document.querySelectorAll("h2, h3, h4, h5, h6"),
);
for (const heading of headings) {
heading.classList.add("group");
const link = document.createElement("a");
link.className =
"heading-link ml-2 opacity-0 group-hover:opacity-100 focus:opacity-100";
link.href = "#" + heading.id;
const span = document.createElement("span");
span.ariaHidden = "true";
span.innerText = "#";
link.appendChild(span);
heading.appendChild(link);
}
}
addHeadingLinks();
/** Attaches copy buttons to code blocks in the document,
* allowing users to copy code easily. */
function attachCopyButtons() {
const copyButtonLabel = "Copy";
const codeBlocks = Array.from(document.querySelectorAll("pre"));
for (const codeBlock of codeBlocks) {
const wrapper = document.createElement("div");
wrapper.style.position = "relative";
const copyButton = document.createElement("button");
copyButton.className =
"copy-code absolute right-3 -top-3 rounded bg-muted px-2 py-1 text-xs leading-4 text-foreground font-medium";
copyButton.innerHTML = copyButtonLabel;
codeBlock.setAttribute("tabindex", "0");
codeBlock.appendChild(copyButton);
// wrap codebock with relative parent element
codeBlock?.parentNode?.insertBefore(wrapper, codeBlock);
wrapper.appendChild(codeBlock);
copyButton.addEventListener("click", async () => {
await copyCode(codeBlock, copyButton);
});
}
async function copyCode(block, button) {
const code = block.querySelector("code");
const text = code?.innerText;
await navigator.clipboard.writeText(text ?? "");
// visual feedback that task is completed
button.innerText = "Copied";
setTimeout(() => {
button.innerText = copyButtonLabel;
}, 700);
}
}
attachCopyButtons();
/** Scrolls the document to the top when
* the "Back to Top" button is clicked. */
function backToTop() {
document.querySelector("#back-to-top")?.addEventListener("click", () => {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
});
}
backToTop();
/* Go to page start after page swap */
document.addEventListener("astro:after-swap", () =>
window.scrollTo({ left: 0, top: 0, behavior: "instant" }),
);
/** Add lazy loading to all images in the article */
function addLazyLoading() {
const article = document.querySelector("#article");
if (!article) return;
const images = article.querySelectorAll("img:not([loading])");
images.forEach((img) => {
img.setAttribute("loading", "lazy");
});
}
addLazyLoading();
/** Keyboard navigation for posts */
function setupKeyboardNavigation() {
const navContainer = document.querySelector('[data-prev-url]');
if (!navContainer) return;
const prevUrl = navContainer.getAttribute('data-prev-url');
const nextUrl = navContainer.getAttribute('data-next-url');
document.addEventListener('keydown', (e) => {
// Ignore if user is typing in an input, textarea, or contenteditable
if (e.target.matches('input, textarea, [contenteditable="true"]')) return;
// J key for next post
if (e.key === 'j' && nextUrl) {
window.location.href = nextUrl;
}
// K key for previous post
else if (e.key === 'k' && prevUrl) {
window.location.href = prevUrl;
}
});
}
setupKeyboardNavigation();
/** Process YouTube and Twitter embeds */
function processEmbeds() {
const article = document.querySelector("#article");
if (!article) return;
// Look for YouTube embeds
const youtubeEmbedRegex = /\{% youtube (https:\/\/[^\s]+|[a-zA-Z0-9_-]+) %\}/g;
let foundYoutubeEmbeds = false;
// Helper to extract a YouTube video ID from various URL formats
const extractYouTubeId = (input) => {
let videoId = input;
try {
if (videoId.includes("youtube.com/watch")) {
const url = new URL(videoId);
videoId = url.searchParams.get("v") || "";
} else if (videoId.includes("youtu.be/")) {
videoId = videoId.split("youtu.be/")[1]?.split("?")[0] || "";
} else if (videoId.includes("youtube.com/embed/")) {
videoId = videoId.split("youtube.com/embed/")[1]?.split("?")[0] || "";
}
} catch (_) {
// If URL parsing fails, fall back to the raw input
}
return videoId;
};
// 1) Pre-pass: replace whole-paragraph shortcodes (most common case)
const pNodes = article.querySelectorAll("p");
pNodes.forEach((p) => {
const text = (p.textContent || "").trim();
const ytMatch = text.match(/\{% youtube (https:\/\/[^\s]+|[a-zA-Z0-9_-]+) %\}/);
if (ytMatch && ytMatch[1]) {
foundYoutubeEmbeds = true;
const videoId = extractYouTubeId(ytMatch[1]);
const container = document.createElement("div");
container.className = "youtube-embed-container";
container.innerHTML = `
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/${videoId}"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
`;
p.replaceWith(container);
}
});
// 2) Fallback: process any remaining text nodes that still contain shortcodes
const walker = document.createTreeWalker(
article,
NodeFilter.SHOW_TEXT,
null,
false,
);
const textNodes = [];
let node;
while ((node = walker.nextNode())) {
textNodes.push(node);
}
textNodes.forEach((textNode) => {
let content = textNode.textContent;
let hasChanges = false;
// Process YouTube embeds
content = content.replace(youtubeEmbedRegex, (match, videoId) => {
foundYoutubeEmbeds = true;
hasChanges = true;
videoId = extractYouTubeId(videoId);
return `<div class="youtube-embed-container">
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/${videoId}"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
</div>`;
});
if (hasChanges) {
// Replace the text node with HTML content
const tempDiv = document.createElement("div");
tempDiv.innerHTML = content;
// Replace the text node with the new HTML elements
const parent = textNode.parentNode;
while (tempDiv.firstChild) {
parent.insertBefore(tempDiv.firstChild, textNode);
}
parent.removeChild(textNode);
}
});
}
// Run the embed processing
processEmbeds();
// Also run after astro navigation
document.addEventListener("astro:page-load", processEmbeds);
</script> Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |