A smart, flexible CLI tool to copy source code from a directory (or project) into your clipboard or a text file — while skipping unnecessary files using .ccignore.
- ✅ Recursively finds source code files in a target directory
- 🧹 Ignores folders like
.git,node_modules, etc. using a.copy_codeignorefile - 🎯 Filters by file extension (
--extensions=rb,py,js) - 📋 Copies output to your clipboard or saves to a file (
--print=pbcopy|txt) - 🐚 Works from the terminal with one clean command
| flags | options |
|---|---|
| -e, --extensions=EXT | Comma-separated list of file extensions to include (e.g. -e rb,py) |
| -p, --print=OUT | Output format: pbcopy (clipboard) or txt (file) |
| -o, --output-path=PATH | Output path or directory for txt mode (default: code_output.txt) |
| -h | Show help information |
gem install copy_codeOr clone and build manually:
git clone https://github.com/your_username/copy_code.git
cd copy_code
gem build copy_code.gemspec
gem install ./copy_code-*.gemcopy_code [options] [paths]Copy all .rb and .py files from the current directory and subdirectories:
copy_code -e rb,pyCopy .js, .ts, and .json files from a specific folder and write to a file:
copy_code ~/projects/my-app -e js,ts,json -p txtWrite output to a specific file:
copy_code ~/projects/my-app -e rb -p txt -o ~/tmp/my_code.txtWrite output to the project root:
copy_code ~/projects/my-app -e rb -p txt -o .Copy all .rb and .py files from the current directory and subdirectories:
copy_code -e rb,pyCopy .js, .ts, and .json files from a specific folder and write to a file:
copy_code ~/projects/my-app -e js,ts,json -p txtcopy_code -e rb,pyCopy .js, .ts, and .json files from a specific folder and write to a file:
copy_code ~/projects/my-app -e js,ts,json -p txtcopy_code -e rb,pyYou can create a .ccignore file in your project directory to specify files and directories to ignore. This works similarly to .gitignore.
# Ignore all node_modules directories
node_modules/
# Ignore all .git directories
.git/
# Ignore all log files
*.log
# Ignore all temporary files
*.tmp
# Ignore all coverage directories
coverage/
# Ignore all virtual environments
.venv/
This project is licensed under the MIT License. See the LICENSE file for details.