A Python cli tool to dump out a git project in a cat
-esque way or to pass it along into a text editor in one file
catgit
is a Python CLI tool designed to display the contents of a Git project in a consolidated, readable format directly in your terminal or through a specified text editor. It provides a quick overview of the project's structure, including ignored files based on your .gitignore
settings, and can output all readable files sequentially.
catgit
also supports directly dumping out the entire project straight into your favorite text editor, i.e. to be passed along to a LLM assistant or such with the --editor
flag. It can also be used to get the structural view of regular directories and their file contents, even if they're not Git repositories.
- Project Overview: Outputs the complete directory and file structure of your Git project.
- Gitignore Respect: Respects
.gitignore
files to skip over ignored files or directories. - Flexible Output: Supports output directly to the terminal or opens in a specified text editor like nano or gedit.
- Configurable: Options to toggle the inclusion of the tree view in the output, and choose between terminal output and editor output through configuration.
You can install catgit
directly from the source code:
- Clone the repository:
git clone https://github.com/FlyingFathead/catgit.git
- Navigate to the cloned directory:
cd catgit
- Install the package:
pip install .
Alternatively, if you only want to try out catgit
, navigate to the catgit/
subdirectory and run it with:
python catgit.py /path/to/your/project/
For quick setup after installation, just use:
catgit --setup
catgit
uses a configuration file (config.ini
) which allows the user to set preferences such as:
output_method
: Choose betweenterminal
andeditor
to display the project output.editor_command
: Specify which editor to use when opening the output (e.g.,vim
,nano
,gedit
).ignore_gitignored
: Toggle whether to ignore files as specified in.gitignore
.include_tree_view_in_file
: Decide whether to include the directory tree structure in the concatenated file output.treat_non_git_as_error
: Decide whether to quit if the directory structure is not recognized as a Git repository.
Example configuration (config.ini
):
[Defaults]
# Options: terminal, editor
output_method = terminal
# Specify the command to open the text editor
editor_command = gedit
# ignore .gitignore files
ignore_gitignored = true
# include the tree view in file printout
include_tree_view_in_file = true
# treat "non-git" directory structures as errors (= quit if true)
treat_non_git_as_error = false
To use catgit, navigate to the root directory of the project and run:
catgit /path/to/your/project/
You can also pass the output directly to your editor with the flag --editor
(since v0.10.4
):
catgit /path/to/your/project/ --editor
You will be prompted for an editor if a default isn't found. You can use i.e. vim
, nano
etc on Linux, notepad
on Windows.
0.10.7
- addedThreadPoolExecutor
for faster performance; file sizes; line counting0.10.6
- added thetreat_non_git_as_error
(true/false) config option0.10.5
- git checks made robust and verbose0.10.4
- added--editor
flag for sending straight to text editor, checks for editor and asks the user if not found0.10.3
- improved error catching, absolute paths0.10.2
- switched to usingtempfile
for better cross-platform compatibility0.10.1
- added the--setup
flag for quick setup in cli0.10
- initial public release w/ installer
catgit
was developed by FlyingFathead with contributions from ChaosWhisperer.
This tool is designed to streamline the process of reviewing project contents, making it a neat little utility for developers who manage large or complex Git repositories and/or use LLM-based AI assistants to sort through their codebases.
catgit
is open-source software licensed under the MIT license.