Skip to content

Get Started

Bunmagic is a script management tool that makes it incredibly easy to create and run shell scripts using Bun’s powerful runtime and APIs.

This is the key feature of Bunmagic: All utilities are available as global variables in your scripts. No imports needed for $, args, flags, cd, ack, select, glob, and all other Bunmagic utilities. They’re just there, ready to use!

  1. Install Bun:

    Terminal window
    curl -fsSL https://bun.sh/install | bash
  2. Install Bunmagic:

    Terminal window
    bunx bunmagic install
  3. Create Your First Script:

    Terminal window
    bunmagic create hello-world

    This will create a new script and open it in your editor.

  4. Write Your Script:

    // No imports needed! All bunmagic utilities are global variables!
    console.log(ansis.green("Hello from bunmagic! 🪄"))
    // Run shell commands with $ (no import needed!)
    await $`echo "Running shell commands is easy!"`
    // Use args and flags directly (they're global!)
    if (args[0]) {
    console.log(`You passed: ${args[0]}`)
    }
    // File operations with global utilities
    if (await isDirectory("./src")) {
    const files = await glob("src/*.ts")
    console.log(`Found ${files.length} TypeScript files`)
    }
    // Interactive prompts - also global!
    const name = await ask("What's your name?")
    const confirmed = await ack(`Nice to meet you, ${name}! Continue?`, 'y')
    if (confirmed) {
    const choice = await select("Pick your favorite:", ["Bun", "Node", "Deno"])
    console.log(`Great choice: ${choice}!`)
    }
  5. Run Your Script:

    Terminal window
    hello-world

    That’s it! Your script is now available as a command in your terminal.

  • Explore Bunmagic Commands to learn how to manage your scripts
  • Check the Script Basics to understand arguments, flags, and shell execution
  • Browse the Reference for all available APIs and utilities