Files
gitignore-gen/app/gitignore-gen

gitignore-gen

A Rust CLI tool that generates .gitignore files from 100+ programming language/framework templates. Features interactive TUI template selection, template combination, custom pattern addition, search/filter, and contribution workflow for new templates.

CI License Rust

Features

  • 100+ Templates: Built-in support for popular languages, frameworks, IDEs, and tools
  • Template Combination: Merge multiple templates into a single .gitignore file
  • Interactive TUI: Visual interface for browsing and selecting templates
  • Search & Filter: Find templates by name or filter by category
  • Custom Patterns: Add your own patterns to the generated .gitignore
  • Version Tracking: Keep track of template versions and updates
  • Contribution Workflow: Easy process for contributing new templates

Installation

From Source

git clone https://github.com/yourusername/gitignore-gen
cd gitignore-gen
cargo install --path .

From Cargo

cargo install gitignore-gen

Usage

Generate a .gitignore from a template

# Generate for a specific language/framework
gitignore-gen generate --template rust
gitignore-gen generate --template python
gitignore-gen generate --template react

# Output to a specific file
gitignore-gen generate --template rust --output project/.gitignore

# Combine multiple templates
gitignore-gen generate --combine rust,python,nodejs --output .gitignore

# Add custom patterns
gitignore-gen generate --template rust --custom "*.log,.env" --append

List available templates

# List all templates
gitignore-gen list

# Filter by category
gitignore-gen list --category language
gitignore-gen list --category framework
gitignore-gen list --category ide

# Search templates
gitignore-gen list --search rust

Search for templates

# Search by name
gitignore-gen search rust
gitignore-gen search python
gitignore-gen search react

# Find templates matching a pattern
gitignore-gen search web

Interactive mode

Launch the interactive TUI for visual template selection:

gitignore-gen interactive

Show template information

# Get details about a template
gitignore-gen info rust

Check for updates

# Check if templates are up to date
gitignore-gen update

Commands

Command Alias Description
generate gen Generate a .gitignore file
list ls List available templates
search find Search for templates
interactive - Launch interactive TUI
contribute - Contribute a new template
info - Show template information
update - Check for template updates

Interactive Mode

The interactive TUI provides a visual interface with the following features:

  • Browse templates organized by category
  • Search using the / key
  • Select multiple templates with SPACE
  • Generate your .gitignore with ENTER or g
  • Clear selection with c
  • Help available with ?

Keyboard Shortcuts

Key Action
SPACE Toggle template selection
ENTER Confirm selection / Generate
/ Search templates
c Clear selection
g Generate .gitignore
? Show help
ESC Go back / Cancel
↑/↓ Scroll through templates

Template Categories

  • Language: Programming languages (Rust, Python, Go, Java, etc.)
  • Framework: Web frameworks (React, Django, Rails, etc.)
  • IDE: Development environments (VSCode, JetBrains, Vim, etc.)
  • Build Tool: Build systems (Gradle, Maven, CMake, etc.)
  • OS: Operating systems (Windows, macOS, Linux)
  • Database: Database systems (MySQL, PostgreSQL, MongoDB, etc.)
  • Version Control: VCS tools (Git, SVN, Mercurial)
  • Documentation: Documentation tools (LaTeX, Sphinx, etc.)
  • Testing: Testing frameworks (Jest, Pytest, Mocha, etc.)
  • Misc: Miscellaneous templates

Contributing Templates

Want to add a new template? It's easy!

# Generate a template scaffold
gitignore-gen contribute my-new-template

# Fill in the template file
# Submit a PR at https://github.com/yourusername/gitignore-gen

Template Format

Templates follow a simple JSON format:

{
  "name": "my-template",
  "category": "Language",
  "patterns": [
    "*.log",
    "target/",
    ".env"
  ],
  "description": "A description of the template"
}

Configuration

Configuration is read from ~/.config/gitignore-gen/config.json:

{
  "template_path": "~/.cache/gitignore-gen/templates",
  "auto_update_templates": false,
  "show_categories": true
}

Examples

Basic usage

# Generate a Python .gitignore
gitignore-gen generate --template python --output .gitignore

Combining multiple templates

# Create a full-stack project .gitignore
gitignore-gen generate \
  --combine rust,react,postgresql,docker \
  --output .gitignore

With custom patterns

# Add project-specific patterns
gitignore-gen generate \
  --template rust \
  --custom "*.custom,docs/" \
  --output .gitignore
# Find all Python-related templates
gitignore-gen search python

Development

Building

cargo build --release

Testing

# Run all tests
cargo test --all

# Run integration tests only
cargo test --test integration

# Run unit tests only
cargo test --unit

# Run with coverage
cargo tarpaulin --out Html

Linting

# Check formatting
cargo fmt --check

# Run clippy
cargo clippy

Adding New Templates

  1. Add the template content to src/templates/loader.rs
  2. Update the init_embedded_templates() function
  3. Add the template to the appropriate category
  4. Run tests to verify
  5. Submit a PR

License

MIT License - see LICENSE for details.

Acknowledgments