Create `.gitignore` files using one or more templates from TopTal, GitHub or your own collection

Overview

gitnr

A cross-platform CLI utility to create .gitignore files using templates.

  • Use templates from the GitHub & TopTal collections
  • Use local files and remote URLs as templates
  • Filter out duplicate ignore lines when using multiple templates
  • Interactive mode to search and select templates
  • Cross-platform support (Windows, macOS, Linux)
# Create an ignore file for Rust with CLion IDE
gitnr create gh:Rust tt:clion+all

# Interactively search and select templates
gitnr search 

gitnr demo

Table of Contents

Installation

Linux & Mac

Run any of the commands below in your terminal to install the latest version of gitnr.

Install system-wide

curl -s https://raw.githubusercontent.com/reemus-dev/gitnr/main/scripts/install.sh | sudo bash -s

Install for current user

curl -s https://raw.githubusercontent.com/reemus-dev/gitnr/main/scripts/install.sh | bash -s -- -u

On Linux this defaults to $HOME/.local/bin and on macOS to $HOME/bin. The script will fail if the directory doesn't exist or is not in your system path.

Install in specific directory

curl -s https://raw.githubusercontent.com/reemus-dev/gitnr/main/scripts/install.sh | bash -s -- -d <dir>

Windows

Run the command below in a PowerShell terminal to install the latest version of gitnr.

Set-ExecutionPolicy Unrestricted -Scope Process; iex (iwr "https://raw.githubusercontent.com/reemus-dev/gitnr/main/scripts/install.ps1").Content

Binary Download

See the releases page to download a binary and then add it to a directory in your system path.

From Source

git clone --depth=1 github.com/reemus-dev/gitnr
cd gitnr
cargo install --path .

Note: This requires that you have Rust and cargo installed on your system.

Usage

There are 3 commands available

Command Description
create Create a .gitignore file and print the content to stdout or save it to a file
search Interactive mode to search and select templates from the GitHub and TopTal collections. You can then copy the result to your clipboard or copy the relevant create command to generate your ignore file
help Display the CLI help message with available flags & commands

Create

The create command accepts a list of templates to generate a .gitignore file with.

gitnr create [FLAGS] [TEMPLATES]...

Create Template Arguments

Templates can be provided to the CLI as:

  • Space separated or comma separated values
  • With or without their source prefix

The following template sources are available:

Template Sources Prefix
URL url:
File file:
GitHub (a file from any public repo) repo:
GitHub Templates gh:
GitHub Community Templates ghc:
GitHub Global Templates ghg:
TopTal Templates tt:

For example:

# With prefix
gitnr create gh:Node

# Without prefix
gitnr create Node

# Combining templates - a project using Node.js + Vue in WebStorm
gitnr create gh:Node ghc:JavaScript/Vue tt:webstorm+all

# Using a remote URL and local file
gitnr create url:https://domain.com/template.gitignore file:path/to/local.template.gitignore

# Using a file from a GitHub repo
gitnr create repo:github/gitignore/main/Rust.gitignore

If you do not prefix the template, the CLI will try to automatically detect the template source. If it can't match the template name to a source, it defaults to checking the GitHub template collection. It's advised to be explicit about the source prefix to avoid any ambiguity.

Templates from the GitHub and TopTal collections do not need to have the .gitignore, .stack or .patch suffixes. Meaning you can use gh:Rust instead of gh:Rust.gitignore or tt:webstorm+all instead of tt:webstorm+all.patch.

The generated template will be created in the order of the template arguments supplied.

Note
The TopTal template collection includes stacks and patches. A stack specifies multiple ignore templates that are combined, e.g. Angular.stack. The patch extension add modifications to the original template from GitHub's collection.

Create Flags

By default, the resulting .gitignore template is printed to stdout. You can customize this behaviour using the CLI flags available:

Flag Short Description
--save -s Write template to .gitignore file in current directory (overwriting any exiting file)
--file <path> -f <path> Write template to the specified file path overwriting any exiting file
--refresh -r Refresh the template cache (templates are cached for 1 hour by default)

Search

The search command allows you to interactively browse, filter and select templates from the GitHub and Toptal collections.

gitnr search

This is useful when you want to see what's available and preview different template combinations. You will be able to preview an individual template as well as preview a template combination.

The search command only has one flag, which is --refresh | -r. This allows you to refresh the template cache which by default caches the template collections for 1 hour. This is to avoid hitting the API rate-limits.

Why This Exists?

  • I wanted a way to template my .gitignore files for all projects to keep things consistent.
  • I wanted to build a .gitignore from multiple templates to keep things modular
  • I wanted to build something with Rust and learn the language
  • And apparently I wanted to waste more time than I'd like to on a simple side project 😅

Contributing

Open a PR or create an issue with any suggestions. Given this is my first Rust application, veterans will probably spot a lot of things that can be improved, refactored or removed. So feel free to open a PR or issue with any suggestions.


Improve your software dev skills by learning from my programming struggles at https://reemus.dev

You might also like...
Get your github contributions right in your terminal, blazingly fast!
Get your github contributions right in your terminal, blazingly fast!

GitColorScripts Get your github contributions right in your terminal! Installation Install via yay yay -S gitcolorscripts Install manually Download t

YAML(ish) - Terminal UI framework based on templates focused on simplicity
YAML(ish) - Terminal UI framework based on templates focused on simplicity

A YAML(ish) based terminal GUI framework for- and by Rust, focussed on making it quick and easy to create a functional UI for an app or game. Based on Crossterm and inspired by Kivy.

Core Fiberplane data models and methods for transforming them (templates, providers, markdown conversion)

fiberplane This repository is a monorepo for Rust code that is used throughout Fiberplane's product. Overview base64uuid - A utility for working with

tmplt is a command-line interface tool that allows you to quickly and easily set up project templates for various programming languages and frameworks
tmplt is a command-line interface tool that allows you to quickly and easily set up project templates for various programming languages and frameworks

tmplt A User Friendly CLI Tool For Creating New Projects With Templates About tmplt is a command-line tool that lets users quickly create new projects

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project.

SKYULL is a command-line interface (CLI) in development that creates REST API project structure templates with the aim of making it easy and fast to start a new project. With just a few primary configurations, such as project name, you can get started quickly.

⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.

This repository lists static analysis tools for all programming languages, build tools, config files and more. The official website, analysis-tools.de

A cli tool to download specific GitHub directories or files

cloneit A cli tool to download specific GitHub directories or files. Installation From git git clone https://github.com/alok8bb/cloneit cd cloneit car

A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.
A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.

FileQL - File Query Language FileQL is a tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK. Sampl

mdBook is a utility to create modern online books from Markdown files.

Create book from markdown files. Like Gitbook but implemented in Rust

Owner
reemus.dev
Complex fails, simple scales
reemus.dev
A Rust based simple cli to delete all files included in `.gitignore` file from your repo

clean-local A simple CLI to remove all the files and folders included in the .gitignore file. Written in RUST Supports glob and wildcard paths in .git

Vilva Athiban P B 5 Jul 8, 2023
🎒 CLI to create starters from repos + Templates 🤖 + Actions 🚀

Backpack A tool to curate and automate your starter projects Key Features • How To Use • Download • Contributing • License Key Features Generate from

Rusty Ferris Club 30 Mar 6, 2023
A little tool to create region-free openingTitle.arc files for New Super Mario Bros. Wii, or to convert them from one region to another

smallworld ...though the mountains divide and the oceans are wide... smallworld is a little tool that can create region-free openingTitle.arc files fo

NSMBW Community 7 Feb 6, 2023
A rust binary that will flip one or more bits of a file (mostly for messing with images for fun).

file-bitflipper A rust binary that will flip one or more bits of a file (mostly for messing with images for fun). Example (bitflipped bentley) Usage $

null 1 Aug 31, 2022
A super simple /sbin/init for Linux which allows running one and only one program

Summary High-performance /sbin/init program for Linux This is designed to do literally nothing but accept binaries over the network and run them as a

null 19 Dec 4, 2023
BoilerFiles is a CLI for downloading your boilerplate files from a public GitHub template repo.

BoilerFiles Available on crates.io. BoilerFiles is a CLI for downloading your boilerplate files from a public GitHub template repo. Features Are you t

Jan Müller 4 Oct 1, 2022
A toolkit for building your own interactive command-line tools in Rust

promkit A toolkit for building your own interactive command-line tools in Rust, utilizing crossterm. Getting Started Put the package in your Cargo.tom

null 70 Dec 18, 2022
A bring-your-own-mutex version of once_cell.

generic_once_cell generic_once_cell is a generic no_std version of once_cell. Internal synchronization for initialization is provided as type paramete

Martin Kröning 3 Nov 28, 2022
Write your own exploit for $CASH

Cashio Exploit Workshop The Cashio hack was one of the biggest hacks occurred in Solana ecosystem which allowed the attacker to print infinite amount

Narya.ai 21 Mar 22, 2023
A mansplainer for man commands, cheeky and rude, use at your own risk

mansplain mansplain is a Command-Line Interface (CLI) tool built in Rust that mansplains a command to you Prerequisites Rust and Cargo installed An Op

Pratik Kanthi 3 Oct 24, 2023