>mir

Getting Started with mir

// Learn how to install mir and start using code snippets

What is mir?

mir is a command-line tool for sharing and installing reusable code snippets. A snippet can be anything from a single function to a complete directory structure with multiple files. Use mir to save time on repetitive code and maintain consistency across your projects.

Installation

Option 1: Using npx (Recommended)

Run mir directly without installing:

// terminal
npx @tbsten/mir --help

Option 2: Global Installation

Install mir globally on your system:

// terminal
npm install -g @tbsten/mir
mir --help

Quick Start

Step 1: Initialize a Project

Create a new mir project in your current directory:

// terminal
npx @tbsten/mir init

This creates a .mir/ directory with sample snippets and configuration.

Step 2: View Available Snippets

List snippets in your local registry:

// terminal
npx @tbsten/mir list

Step 3: Install a Snippet

Install a snippet from the official registry:

// terminal
npx @tbsten/mir install react-hook

mir will prompt you for any required variables, then generate the files.

Step 4: Create Your Own Snippet

Create a new snippet template:

// terminal
npx @tbsten/mir create my-snippet

Edit the generated .mir/snippets/my-snippet.yaml and template files, then publish:

// terminal
npx @tbsten/mir publish my-snippet

Core Concepts

Snippets

A snippet is a reusable collection of template files with configurable variables. When you install a snippet, mir generates files with your custom values substituted in.

Registries

Registries store snippets. mir supports both local registries (~/.mir/registry/) and remote registries (e.g., the official registry at mir.tbsten.me).

Variables

Variables are placeholders in your snippet templates. When installing, mir prompts you for values and substitutes them using Handlebars syntax (e.g., {{variableName}}).

Common Commands

CommandDescription
npx @tbsten/mir initInitialize a new mir project
npx @tbsten/mir listList snippets in registry
npx @tbsten/mir info <name>Show snippet details
npx @tbsten/mir search <query>Search snippets
npx @tbsten/mir install <name>Install a snippet
npx @tbsten/mir create <name>Create a new snippet
npx @tbsten/mir publish <name>Publish a snippet

Next Steps

Need Help?

Use npx @tbsten/mir --help to view all available commands and options.

For more information, visit the GitHub repository.