Have you ever wanted to ask a question about a project to a LLM but lost a lot of time trying to explain the structure of the project and the relevant files?
cctx is a command-line tool that allows you to recursively print the file tree of a specified directory, display contents of specified files, and ignore certain paths or the entire tree. It's useful for quickly understanding the structure and content of a project in the context of a question.
- Recursively print file trees: Visualize the directory structure of your project.
- Display file contents: Easily view the contents of specified files.
- Ignore paths: Exclude certain files or directories from the tree.
- Ignore entire tree: Focus solely on specified files without displaying the tree.
- Specify line ranges: Display specific lines from files.
You can install cat-context via pip:
pip install cat-contextThis will install the cat-context package and make the cctx command available globally.
cctx [OPTIONS] [FILE_PATHS...]--cwd <path>: Change the current working directory. Defaults to the current directory.-ip,--ignore-path <path>: Paths to ignore in the file tree (relative to cwd or absolute). Can be used multiple times to ignore multiple paths.-it,--ignore-tree: Ignore the entire tree and only display specified files.
FILE_PATHS: One or more files to display contents of if they exist in the tree. You can specify line numbers using the formatpath:start_line:end_line.
cctx README.md cctx/main.pycctx cctx/main.py:10:20cctx --ignore-tree README.mdcctx --ignore-path=folder1 --ignore-path=folder2cctx --cwd=/path/to/directoryIf you want to run ctx in development mode or contribute to the project, follow these steps.
git clone https://github.com/asnunes/ctx.git
cd cctxMake sure you have Python 3 installed. It's recommended to use a virtual environment.
python3 -m venv venv
source venv/bin/activate # On Windows use venv\Scripts\activatepip install -e .cctx [OPTIONS] [FILE_PATHS...]Or directly via Python:
python cctx/main.py [OPTIONS] [FILE_PATHS...]python cctx/main.py --cwd=. README.mdTo run the tests, use the unittest module from the root directory.
python -m unittest discover testsThis project is licensed under the MIT License. See the LICENSE file for details.