Concatenate your project’s source files into a single, navigable Markdown document — complete with syntax highlighting, table of contents, and clipboard export.
SourceConcat.jl walks your source tree, collects files that match glob patterns, and concatenates them into a single Markdown file.
It’s handy for:
- Building context packs for AI tools or documentation
- Creating portable snapshots of a codebase
- Rapid code reviews and shareable archives
using Pkg
Pkg.add(url="https://github.com/josePereiro/SourceConcat.jl.git")- Put a configuration file at your project root named
SourceConcat.json(orSrcConcat.json). - From Julia, call:
using SourceConcat
concat(log = true)| Mode | Description |
|---|---|
"file" |
Write concatenated Markdown to output.path. |
"clipboard-text" |
Copy concatenated text to the clipboard (up to an internal size limit). |
"clipboard-file" |
Write the file to disk and copy a file reference to the clipboard. |
"terminal" |
Print the concatenated Markdown to stdout. |
| Key | Type | Description |
|---|---|---|
root.paths |
Vector{String} |
Root directories to walk |
output.path |
String |
Destination Markdown path |
output.mode |
String |
One of: "file", "clipboard-text", "clipboard-file", "terminal" |
include.files |
Vector{String} |
Glob patterns to include |
exclude.files |
Vector{String} |
Glob patterns to exclude |
use.gitignore |
Bool |
When true, patterns in .gitignore are respected for exclusion |
Config filenames: either
SourceConcat.jsonorSrcConcat.jsonis recognized.
<!-- Generated by SourceConcat.jl at 2025-11-08 10:15:44 -->
***
## TABLE OF CONTENTS
1. [Content of 'Project.toml'](#sc-1)
2. [Content of 'src/SourceConcat.jl'](#sc-2)
...Add one of these to your ~/.bashrc or ~/.zshrc.
alias srcconcat='julia -e "using SourceConcat; SourceConcat.concat()"'Usage:
# From a repo that has SourceConcat.json
srcconcatsrcconcat() {
# global
julia -e 'using SourceConcat; SourceConcat.concat()'
}Examples:
# Use the active environment
srcconcatThe function simply invokes
SourceConcat.concat()in the current working directory, where the tool will look forSourceConcat.json.
When output.mode is "clipboard-file", the Markdown is written to disk and a file reference is copied to your clipboard, so you can paste directly into a AI chat as an attachment.
| Platform | Backend | Details |
|---|---|---|
| macOS | osascript |
AppleScript: set the clipboard to POSIX file "..." |
| Windows | PowerShell |
Uses .NET System.Windows.Forms.Clipboard via STA thread |
| Linux | wl-copy / xclip |
GNOME-compatible x-special/gnome-copied-files, falls back to text/uri-list |
Implementation: src/utils.clipboard.file.jl
using Pkg
Pkg.test("SourceConcat")Planned:
- Nested
.gitignoreparsing and!patternsupport - Parallel reading for large trees
- Command-line interface
- HTML / JSON export options
SourceConcat.jl/
├── Project.toml
├── SourceConcat.json # example configuration
├── data/
│ └── SourceConfig.example.json
├── src/
│ ├── SourceConcat.jl
│ ├── base.*.jl
│ ├── utils.clipboard.file.jl
│ ├── utils.gitignore.jl
│ └── utils.config.example.jl
├── test/
│ └── runtests.jl
└── notes/
MIT © 2025 José Pereiro
{ "root.paths": [ "." ], "output.path": "~/Documents/context.md", "output.mode": "clipboard-file", "include.files": [ "*.jl", "*.md", "*Project.toml", "*SourceConcat.json" ], "exclude.files": [ "_DEPRECATED/**", ".git/**", "dev/**" ], "use.gitignore": true }