Rust CLI implementation of
concatfromconcat-zsh.
concat merges the contents of multiple files (and/or directories) into a single output file, for use as context in LLM prompts or general file aggregation.
Preferred (uses the repo install script with conflict warnings):
./installBypass prompts (for CI/non-interactive use):
./install --force- If you still have
concat-zshsourced as a Zsh function namedconcat, it will shadow the Rust binary. Usecommand concat ...or remove the function from your shell config.
concat [OPTIONS] [FILE|DIR|GLOB...]
concat clean [OPTIONS] [DIR...]If no inputs are provided, concat defaults to ..
- Default output format is XML.
- Use
-t, --textfor plain text output. - Output filenames default to
_concat-*unless-o, --outputis provided. Use-y, --clipboardto copy the output to your clipboard instead of writing a file. - A metadata header (line and character counts per file) is included by default; disable with
-M, --no-metadata.
-x <ext>once:_concat-<ext>.xml(or.txtwith--text)-xmultiple times:_concat-output.xml- No args at all:
_concat-<cwd>.xml - One directory input:
_concat-<dir>.xml - Otherwise:
_concat-output.xml
-o, --output <file>: output file name-y, --clipboard: copy the generated output to the system clipboard instead of writing a file-r, --recursive: search directories recursively (default)-n, --no-recursive: do not recurse-t, --text: plain text output (default XML)-x, --ext <ext>(repeatable): include only these extensions-g, --ignore-ext <ext>(repeatable): exclude these extensions-I, --include <glob>(repeatable): include only paths matching these globs-e, -E, --exclude <glob>(repeatable): exclude paths matching these globs-T, --tree: include a directory tree of the current directory in the output-H, --hidden: include hidden files/directories-P, --no-purge-pycache: do not remove__pycache__and.pycin the current directory-C, --no-clean-concat: do not delete existing_concat-*files in the current directory before writing-b, --include-binary: include non-text files (encoded as base64)-M, --no-metadata: omit the per-file metadata header (line/character counts)--metadata-sort <mode>: order metadata bylines(default),characters, ornatural(original matched order)-l, --no-dir-list: omit the matched directory list section (XML only)-v, --verbose: verbose logging-d, --debug: extra debug logging
Hidden files + include globs
By default, hidden files are skipped. You can either:
- Pass
-H, --hidden, or - Use an
--includeglob that explicitly targets hidden paths (for example**/.env), without enabling full hidden traversal globally.
Deletes previously generated _concat-* files from the given directories (default: .). Searches recursively by default; use -n to disable recursion. Supports -x/-g/-I/-e/-H similarly to the main command.
Build locally:
cargo buildBuild an optimized binary:
cargo build --releaseRun checks:
cargo fmt
cargo clippy --all-targets --all-features -- -D warnings
cargo test