A command-line tool that aggregates file and directory contents into your clipboard, perfect for providing project context to AI chatbots in your browser like ChatGPT, Perplexity etc.
cxt_demo.mp4
Watch the demo to see cxt
in action - interactive file selection and clipboard aggregation
When you're working in the terminal and need to quickly share your project's code structure and contents with an AI assistant, cxt
makes it effortless. Instead of manually copying files one by one, you can select multiple files and directories, and cxt
will aggregate all their contents with clear path headers, giving the AI full context of your project structure.
The easiest way to install cxt
on any system:
curl -sSfL https://raw.githubusercontent.com/vaibhav-mattoo/cxt/main/install.sh | sh
This script will automatically detect your system and install the appropriate binary.
Remember to add ~/.local/bin
to your $PATH
if prompted by the install script, by adding export PATH="$HOME/.local/bin:$PATH"
in the end of your shell config(~/.bashrc, ~/.zshrc etc).
cargo install cxt
You can install cxt
through brew on Linux or macOS by:
brew tap vaibhav-mattoo/cxt
brew install cxt
You can install cxt
directly from the AUR:
yay -S cxt
# or
paru -S cxt
git clone https://github.com/vaibhav-mattoo/cxt.git
cd cxt
cargo install --path .
Launch the interactive file selector:
cxt
# or
cxt --tui
Navigate with arrow keys or hjkl
, select files/directories with Space
, and confirm with c
.
Wildcard functionality is now supported! You can use patterns like ".py" or "src/**/.rs".
Copy specific files to clipboard:
cxt file1.txt file2.py src/
# Copy a single file to clipboard
cxt main.rs
# Copy multiple files and directories
cxt src/ tests/ README.md Cargo.toml
# Print to stdout and copy to clipboard
cxt -p src/
# Write to a file and copy to clipboard
cxt -w output.txt src/
# Use relative paths in headers
cxt -r src/
# Disable path headers entirely
cxt -n src/
# Include hidden files when walking directories
cxt --hidden src/
# Print to stdout with relative paths and copy to clipboard
cxt -p -r src/ tests/
# Write to file with no path headers
cxt -w output.txt -n src/
# Ignore a directory while copying a project
cxt -i bin src/
The Terminal User Interface (TUI) provides an intuitive way to browse and select files:
- Arrow keys or hjkl: Move cursor
- Space: Select/unselect file or directory
- Enter or l or β: Open directory
- Backspace or h or β: Go to parent directory
- c: Confirm selection and exit
- q: Quit without selection
- Visual selection: Selected items are highlighted
- Directory expansion: Selecting a directory includes all files within it
- Path toggles: Press
r
to toggle relative paths,n
to toggle no path headers
-p, --print
: Print content to stdout (also copies to clipboard)-w, --write <FILE>
: Write content to specified file-t, --tui
: Launch interactive TUI file selector
-r, --relative
: Use relative paths in headers-n, --no-path
: Disable file path headers--hidden
: Include hidden files when walking directories-i, --ignore <PATH>
: Ignore a file or directory (only one allowed)
# Interactive selection
cxt --tui
# Print with relative paths
cxt -p -r src/
# Write to file, no path headers
cxt -w context.txt -n src/ tests/
# Include hidden files
cxt --hidden src/
By default, cxt
adds path headers to distinguish between files:
--- File: /path/to/file1.txt ---
Content of file1.txt
--- File: /path/to/file2.py ---
Content of file2.py
With --relative
, paths are shown relative to current directory:
--- File: file1.txt ---
Content of file1.txt
--- File: src/file2.py ---
Content of file2.py
With --no-path
, only raw content is included:
Content of file1.txt
Content of file2.py
Perfect for providing project context to AI assistants and sharing code snippets with colleagues:
# Quick project overview
cxt --tui
# Specific files for debugging
cxt -r main.rs error.log
# Full project structure
cxt -r src/ tests/ README.md
MIT License - see LICENSE file for details.
To uninstall cxt
, you can run the command:
curl -sSfL https://raw.githubusercontent.com/vaibhav-mattoo/cxt/main/uninstall.sh | sh
If you installed the software using a package manager, remove it using the package manager's uninstall command.