A CLI tool for extracting and sharing code files and functions. A manual context builder for pasting into llms.
Project description
ggrab - Grug Grab Tool
A CLI tool for manually building context to paste into llm chats. ggrab gathers functions, classes, or entire files wraps them with xml and copies it to the clipboard.
Key Features
- Smart Extraction: Grab entire files or specific functions/classes
- Intelligent Autocompletion: File paths and function/class names
- Token Counting: Built-in token counting for AI context limits
- Language Support:
- Python (AST-based extraction)
- JavaScript (Esprima-based extraction)
- Other files (full file extraction)
Quick Start
- Install:
pip install ggrab # Basic install
# or
pipx install ggrab # Recommended
Why pipx? The
pipxinstall is recommended because it:
- Won't interfere with other Python projects (creates its own venv)
- Makes ggrab available globally in your terminal
- Setup:
Add the following to your shell config file (~/.bashrc, ~/.zshrc, or equivalent):
# Enable ggrab autocompletion
eval "$(register-python-argcomplete ggrab)"
Then reload your shell configuration:
# For bash
source ~/.bashrc
# For zsh
source ~/.zshrc
Usage
# Grab entire files
ggrab file.py
# Extract specific functions
ggrab file.py function1 function2
# Mix multiple files and functions
ggrab file1.py func1 func2 file2.js func3
Press TAB at any time for smart autocompletion:
- After
ggrab: Shows file suggestions - After selecting a file: Shows available functions/classes
Examples
# Extract multiple functions from a Python file
$ ggrab utils.py parse_data validate_input
Gathered code from:
- utils.py, functions: parse_data, validate_input (203 tokens)
===== Combined Snippets (copied to clipboard) =====
# Extract from multiple files
$ ggrab api.py handle_request db.js queryDatabase
Gathered code from:
- api.py, functions: handle_request (156 tokens)
- db.js, functions: queryDatabase (178 tokens)
Total tokens across all files: 334
Performance Features
- Lazy Loading: Heavy dependencies load only when needed
- Smart Caching: Function/class listings cached for quick access
- Hybrid Parsing: Fast regex for completion, accurate AST/Esprima for extraction
Requirements
- Python 3.7+
- Required:
argcomplete - Optional but recommended:
pyperclip(clipboard support)tiktoken(token counting)esprima(JavaScript parsing)
Advanced Setup
Disable completion sorting (optional):
complete -o nosort -F _python_argcomplete ggrab
For zsh users:
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit
eval "$(register-python-argcomplete ggrab)"
Acknowledgments
- Developed -- ok, prompted into existance by Claude 3.5, o1 pro. Fixed up to working order by Keizo Gates making GrugNotes :)
License
MIT License
For bug reports and feature requests, please open an issue on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ggrab-0.1.0a7.tar.gz.
File metadata
- Download URL: ggrab-0.1.0a7.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f6aa32604ce137587056d5ddeca436c53bb9064996e9ab96e28684fba01feb4
|
|
| MD5 |
63ae264feac1d3f859d78145d9df6662
|
|
| BLAKE2b-256 |
4739adc43f9b08edb13d670903fcc717b7155562d1dae42cab57d31d2488899b
|
Provenance
The following attestation bundles were made for ggrab-0.1.0a7.tar.gz:
Publisher:
python-publish.yml on keizo/ggrab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ggrab-0.1.0a7.tar.gz -
Subject digest:
2f6aa32604ce137587056d5ddeca436c53bb9064996e9ab96e28684fba01feb4 - Sigstore transparency entry: 157339096
- Sigstore integration time:
-
Permalink:
keizo/ggrab@a1bad98e40302e9176c74a88263187d9e3f30c5d -
Branch / Tag:
refs/tags/v0.1.0a7 - Owner: https://github.com/keizo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a1bad98e40302e9176c74a88263187d9e3f30c5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file ggrab-0.1.0a7-py3-none-any.whl.
File metadata
- Download URL: ggrab-0.1.0a7-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7176385a2d793f77cb8d29dd51087dfc5b6ab40c64383f6ec6d0b30031b09efd
|
|
| MD5 |
2eec82738e1baa75259db6df6da21890
|
|
| BLAKE2b-256 |
43e28c7e62b9fa90fdc83a5a179504385d558fde228f6addd22738e15ab58d59
|
Provenance
The following attestation bundles were made for ggrab-0.1.0a7-py3-none-any.whl:
Publisher:
python-publish.yml on keizo/ggrab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ggrab-0.1.0a7-py3-none-any.whl -
Subject digest:
7176385a2d793f77cb8d29dd51087dfc5b6ab40c64383f6ec6d0b30031b09efd - Sigstore transparency entry: 157339097
- Sigstore integration time:
-
Permalink:
keizo/ggrab@a1bad98e40302e9176c74a88263187d9e3f30c5d -
Branch / Tag:
refs/tags/v0.1.0a7 - Owner: https://github.com/keizo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a1bad98e40302e9176c74a88263187d9e3f30c5d -
Trigger Event:
release
-
Statement type: