Skip to main content

Generate .gitignore files from the command-line

Project description

gitig

Generate .gitignore files from the command-line

PyPI Crates.io

gitig writes its output to stdout. Redirect the results to wherever makes sense for you, for example:

gi python > .gitignore

Installation

With cargo

gitig has an implementation in Rust (and an implementation in Python) and can be installed via cargo:

cargo install gitig-rs

With pipx

gitig is intended to be used as an end-user command-line application (i.e. not as a package's dependency). The easiest way to get started is with pipx:

pipx install gitig

With pip

gitig can also be installed via vanilla pip (or poetry, etc.):

pip install gitig

Usage

$ gi -h
usage: gi [-h] [-v] [--completion {bash,fish}] [--no-pager]
          [template [template ...]]

positional arguments:
  template              Template(s) to include in the generated .gitignore
                        file. If no templates are specified, display a list of
                        all available templates.

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --completion {bash,fish}
                        Generate a completion file for the selected shell.
  --no-pager            Write template list to stdout. By default, this
                        program attempts to paginate the list of available
                        templates for easier reading.

Examples

  • List all available gitignore templates (using a pager if one is available):

    gi
    
  • Generate a gitignore file for Python and Jupyter:

    gi python jupyternotebooks
    

Enable tab completion for Bash or Fish

gitig supports generating completion scripts for Bash and Fish. Below are commands to generate completion scripts for the various shells

For Bash, you will likely have to source (.) the generated tab completion script for it to take effect.

To enable tab completion on startup you can source the completion generated completion script in your .bashrc or .bash_profile.

Bash

gi --completion bash > /etc/bash_completion.d/gi.bash-completion

Bash (Homebrew)

gi --completion bash > $(brew --prefix)/etc/bash_completion.d/gi.bash-completion

Fish

gi --completion fish > ~/.config/fish/completions/gi.fish

Fish (Homebrew)

gi --completion fish > (brew --prefix)/share/fish/vendor_completions.d/gi.fish

API

CLI

gi # query gitignore.io and list available options
gi python jupyternotebooks # write a .gitingore file for python and jupyter to stdout
gi --completion bash # write generated bash autocompletion script to stdout
gi --completion fish # write generated fish autocompletion script to stdout
gi --version # write gitig version info to stdout

Autocompletion

gi <TAB><TAB>
1c                         1c-bitrix                  actionscript
ada                        adobe                      advancedinstaller          adventuregamestudio
agda                       al                         alteraquartusii            altium
...
$ gi python j<TAB><TAB>
jabref  jboss6          jekyll         jetbrains+iml  joe     jupyternotebooks
java    jboss-4-2-3-ga  jenv           jgiven         joomla  justcode
jboss   jboss-6-x       jetbrains      jigsaw         jspm
jboss4  jdeveloper      jetbrains+all  jmeter         julia

Rust API

gitig::list_templates();  // same as `gi`
gitig::create(vec!['python', 'jupyter']);  // same as `gi python jupyter`
gitig::bash_completion();  // same as `gi --completion bash`
gitig::fish_completion();  // same as `gi --completion fish`
gitig::VERSION;

Python API

import gitig

gitig.list_templates()  # same as `gi`
gitig.create(['python', 'jupyter'])  # same as `gi python jupyter`
gitig.bash_completion()  # same as `gi --completion bash`
gitig.fish_completion()  # same as `gi --completion fish`
gitig.__version__

Contributing

Rust

  1. Fork the repo
  2. Run cargo build
  3. Run pre-commit install
  4. Add your changes (adding/updating tests is always nice too)
  5. Commit your changes + push to your fork
  6. Open a PR

Python

  1. Have or install a recent version of poetry (version >= 1.1)
  2. Fork the repo
  3. Setup a virtual environment (however you prefer)
  4. Run poetry install
  5. Run pre-commit install
  6. Add your changes (adding/updating tests is always nice too)
  7. Commit your changes + push to your fork
  8. Open a PR

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitig-23.4.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

gitig-23.4.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file gitig-23.4.0.tar.gz.

File metadata

  • Download URL: gitig-23.4.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

File hashes

Hashes for gitig-23.4.0.tar.gz
Algorithm Hash digest
SHA256 8c1303ff35aff5135ff767e20597799fcb05ea748a70ceb64dccf9c20fcc894f
MD5 9f51661cbeb0e35d60882f282b7f40a8
BLAKE2b-256 fe042424a6c46e7d3c9b26b67ba5f15293e66157eb9713d5b26dee66f5db47e2

See more details on using hashes here.

File details

Details for the file gitig-23.4.0-py3-none-any.whl.

File metadata

  • Download URL: gitig-23.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

File hashes

Hashes for gitig-23.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6791eb411400e6a3995d53a69e56bf6ab953a1db36613dca9702d31980da3de7
MD5 92c009dd446330dcfd409129775586e3
BLAKE2b-256 d6b48b65f402503d8b1dd5f0e93f42d098df1e3ec790d3833861319af5925035

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page