CodeContext is a shell script that scans a project directory and collects all relevant code files into a single output (code_context.txt) or copies them directly to your clipboard. It supports various programming languages and automatically filters files based on language-specific extensions.
To make CodeContext accessible from anywhere, use the included install.sh script.
- Clone or download this repository.
- Make the installer executable:
chmod +x install.sh
- Run the installer:
This will:
./install.sh
- Make the
CodeContext.shscript executable. - Copy it to
/usr/local/bin/CodeContext.
- Make the
If
/usr/local/binrequires root permission:sudo ./install.sh
You can now run CodeContext as a command globally.
CodeContext <project_directory> <language> [output_mode: text|clipboard]<project_directory>β The directory to scan (defaults to current.if not specified).<language>β Programming language to filter relevant files.[output_mode]β Optional:textorclipboard(default isclipboard).
| Language | File Extensions |
|---|---|
| python | .py, .txt, .md, .html, Dockerfile |
| flutter | .dart, .yaml, .txt, .md |
| javascript | .js, .jsx, .json, .html, .css, .txt, .md |
| meteor | .js, .jsx, .ts, .tsx, .json, .html, .css, .md, .txt, .yaml, .yml, .sh, .bash, .meteor, .eslintrc, .prettierrc, .babelrc, .eslintignore, .prettierignore |
| java | .java, .xml, .txt, .md |
| html | .html, .css, .js, .txt, .md, .json |
| css | .css, .html, .js, .txt, .md |
| c | .c, .h, .txt, .md |
| cpp | .cpp, .h, .txt, .md |
-
Copy Python project code from the current directory to clipboard:
CodeContext . python -
Save code context from a Flutter project to a file:
CodeContext /path/to/project flutter text
-
Copy JavaScript project code from any directory:
CodeContext /some/project javascript clipboard
Depending on the mode:
- text β Creates
code_context.txtin the working directory. - clipboard β Copies the result directly using
pbcopy(macOS).
my-python-project/
βββ main.py
βββ module/
β βββ __init__.py
β βββ utils.py
βββ README.md
βββ requirements.txt
Sample Output (code_context.txt):
### ./main.py ###
print("Hello, World!")
### ./module/__init__.py ###
### ./module/utils.py ###
def add(a, b):
return a + b
### ./README.md ###
# Project Title
This is a sample project.
### ./requirements.txt ###
requests
numpy
If using clipboard mode, this will be placed in your system clipboard, ready to paste.