Skip to content

This shell script explores a specified project directory and gathers all the code from relevant files into a single text file called code_context.txt.

Notifications You must be signed in to change notification settings

AbhisarAnand/CodeContext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeContext

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.


πŸš€ Installation

To make CodeContext accessible from anywhere, use the included install.sh script.

Steps:

  1. Clone or download this repository.
  2. Make the installer executable:
    chmod +x install.sh
  3. Run the installer:
    ./install.sh
    This will:
    • Make the CodeContext.sh script executable.
    • Copy it to /usr/local/bin/CodeContext.

If /usr/local/bin requires root permission:

sudo ./install.sh

You can now run CodeContext as a command globally.


🧠 Usage

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: text or clipboard (default is clipboard).

πŸ—‚ Supported Languages

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

πŸ“Œ Examples

  • 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

πŸ“€ Output

Depending on the mode:

  • text β†’ Creates code_context.txt in the working directory.
  • clipboard β†’ Copies the result directly using pbcopy (macOS).

🧾 Sample Project Structure

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.


About

This shell script explores a specified project directory and gathers all the code from relevant files into a single text file called code_context.txt.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages