gitignore-cli is a command-line tool that allows you to easily generate .gitignore files by selecting from pre-defined templates. It leverages the collection of .gitignore templates provided by GitHub and lets you combine multiple templates into a single file.
- Generate
.gitignorefiles from predefined templates. - Combine multiple templates into a single
.gitignorefile. - List available templates.
- Autocomplete support for templates (Bash and Zsh).
- Custom header added to the generated
.gitignorefiles.
To install gitignore-cli-py, we recommend using pipx to ensure the command is globally accessible and isolated from other Python packages.
pipx is a tool to install and run Python applications in isolated environments. First, install pipx if you haven't already:
sudo apt install pipxNow, use pipx to install gitignore-cli-py globally:
pipx install gitignore-cli-pyThis command will make the gitignore-cli command available globally in your terminal. After installing, ensure that pipx is added to your PATH by running:
pipx ensurepathAfter installation, you can verify that gitignore-cli is working by running:
gitignore-cli --helpThis should display the help message for gitignore-cli.
The CLI also supports autocompletion for templates when using Bash or Zsh. To enable autocompletion, follow these steps:
Run the following command to generate the autocomplete script and add the following line to your .bashrc file:
_GITIGNORE_CLI_COMPLETE=bash_source gitignore-cli > ~/.gitignore-cli-complete.sh
echo "source ~/.gitignore-cli-complete.sh" >> ~/.bashrc
source ~/.bashrcRun the following command to generate the autocomplete script and add the following line to your .zshrc file:
_GITIGNORE_CLI_COMPLETE=zsh_source gitignore-cli > ~/.gitignore-cli-complete.sh
echo "source ~/.gitignore-cli-complete.sh" >> ~/.zshrc
source ~/.zshrcTo generate a .gitignore file with one or more templates, use the following command:
gitignore-cli generate <template1> <template2> --output <output_file>For example, to generate a .gitignore file that includes the templates for Python and Node.js, run:
gitignore-cli generate Python Node --output .gitignoreThis will create a .gitignore file combining the templates for Python and Node.js.
To list all the available templates:
gitignore-cli list-templatesThis will output a list of all templates, organized in columns for easier readability.
# Generate a .gitignore file for Python and Node.js
gitignore-cli generate Python Node --output .gitignoreEach generated .gitignore file contains a custom header indicating that the file was generated by gitignore-cli along with the date and a reference to the repository. Example header:
# ======================================
# .gitignore file generated by gitignore-cli
# Generated on: 2024-10-07 01:45:23
# For more information, visit: https://github.com/ninjapythonbrasil/gitignore-cli
# ======================================We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
Please make sure to update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or suggestions, feel free to open an issue or reach out!