{"id":49065702,"url":"https://github.com/jeffrigby/code2clipboard","last_synced_at":"2026-04-20T04:40:11.547Z","repository":{"id":222717018,"uuid":"758158829","full_name":"jeffrigby/code2clipboard","owner":"jeffrigby","description":"A utility to quickly copy code from the CLI in a format suitable for Chatbots","archived":false,"fork":false,"pushed_at":"2025-03-03T02:42:00.000Z","size":136,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T03:28:27.460Z","etag":null,"topics":["chatgpt","cli","clipboard","code-sharing","code-snippets","developer-tools","javascript","nodejs","productivity-tools","programming","source-code-management"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeffrigby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-15T18:31:24.000Z","updated_at":"2025-01-13T16:18:59.000Z","dependencies_parsed_at":"2024-07-11T17:48:41.556Z","dependency_job_id":"e12561a9-945b-45a3-b760-7c7432888411","html_url":"https://github.com/jeffrigby/code2clipboard","commit_stats":null,"previous_names":["jeffrigby/code2clipboard"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jeffrigby/code2clipboard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffrigby%2Fcode2clipboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffrigby%2Fcode2clipboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffrigby%2Fcode2clipboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffrigby%2Fcode2clipboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffrigby","download_url":"https://codeload.github.com/jeffrigby/code2clipboard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffrigby%2Fcode2clipboard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32033025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","cli","clipboard","code-sharing","code-snippets","developer-tools","javascript","nodejs","productivity-tools","programming","source-code-management"],"created_at":"2026-04-20T04:40:10.932Z","updated_at":"2026-04-20T04:40:11.535Z","avatar_url":"https://github.com/jeffrigby.png","language":"JavaScript","readme":"# code2clipboard CLI Tool\n\nThis documentation covers the usage, configuration options, and setup process for the `code2clipboard` (`copy2cb` for short) command-line interface (CLI) tool. This Node.js application is designed to scan a specified directory for source code files, format their content, and copy it to the clipboard for easy pasting elsewhere, such as a GitHub Gist or a ChatGPT.\n\n## Example Output\n\nWhen you run the `code2clipboard` tool, it formats the selected files' content and metadata in markdown format, easily parsed by LLMs.\n\nHere's an example of what the tool copies:\n\n``````````````````````````````````````````````\n## Project Description:\nThis project is a sample hello world project.\n\n## Project Summary:\n- Total Files: 2\n- Total Size: 0.28 KB\n- File Types: MJS (1), JSON (1)\n\n## Tree Structure:\n``````````plaintext\n├── hello.mjs\n└── package.json\n``````````\n\n### Omitted Files\n- .idea (Ignored Directory)\n\n## Files\n### hello.mjs\n- **Size:** 0.06 KB\n- **Last Modified:** 2024-07-05\n- **Content-Type:** application/javascript\n``````````javascript\nexport async function helloWorld() {\n  return 'Hello, world!';\n}\n``````````\n---\n\n### package.json\n- **Size:** 0.22 KB\n- **Last Modified:** 2024-07-05\n- **Content-Type:** application/json\n``````````json\n{\n  \"name\": \"helloworld\",\n  \"version\": \"1.0.0\",\n  \"main\": \"index.mjs\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" \u0026\u0026 exit 1\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"description\": \"\"\n}\n``````````\n---\n``````````````````````````````````````````````\n\nThis output provides a clear and organized way to copy and share code suitable for pasting into apps like ChatGPT, Claude, GitHub Gists, or other chatbots.\n\n## Requirements\n- Node.js (minimum LTS version)\n- npm or yarn\n\n## Installation\nFirst, clone the repository or download the source code to your local machine. Then, navigate to the root directory of the application (`code2clipboard`) and run the following command to install the necessary dependencies:\n\n```sh\nnpm install\n```\nOr, if you use yarn:\n```sh\nyarn install\n```\n\nFor convenience, it's **recommended** to run `npm link` or `yarn link` to make the `code2clipboard` command available globally on your system.\nIt will install the command globally, and you can run it from anywhere in your terminal. It additionally installs a shorthand command `code2cb`.\n\n## Usage\n\nThe `code2clipboard` tool is executed from the command line. Navigate to the root directory of the application and use the following syntax to run the tool:\n```sh\nnode /path/to/code2clipboard.mjs [options]\n```\nOr if you have the command installed globally via `npm link` or `yarn link` you can run this shorthand command from anywhere:\n\n```sh\ncode2cb [options]\n```\n### CLI Options\nThe tool supports several command-line options to customize the scanning and copying behavior, all of which are optional.\n\n- `--max-depth, -d`: Maximum depth for directory scanning. Default: 5.\n- `--max-filesize, -s': Maximum file size in kilobytes (KB) to consider for copying. Default: 100 KB.\n- `--max-files, -f`: Maximum number of files to process and copy to the clipboard. Default: 100.\n- `--add-ignore, -i`: Additional patterns to ignore during file scanning. This parameter should be a CSV string. Use a `*` as a wildcard\n- `--directory, -dir`: Directory to scan for files. Defaults to the current working directory (`process.cwd()`).\n- `--ignore, --oi` Override ignore patterns entirely. Enter multiple entries as CSV. `--ignore node_modules,.git` will ignore both `node_modules` and `.git` directories.\n- `--extensions, -e`: Only copy specific extensions. Specified as a CSV string. Enter multiple extensions as a CSV string. For example, `--extensions js,ts,jsx,tsx,mjs` will only consider JavaScript and TypeScript\n- `--extensions-ignore, --ei`: Ignore specific extensions. Specified as a CSV string. Enter multiple extensions as a CSV string. For example, `--extensions md,txt` will ignore markdown and text files\n- `--omit-tree, --ot`: Omit the visual file tree from the copied content. Defaults to `false`.\n- `--output-to-console, -c`: Output the copied content to the console and the clipboard. Defaults to `false`.\n\n## Configuration Overrides\n\nThe `config.mjs` file holds the default configuration and environment variable management. The default ignores patterns are set in `defaultIgnore.mjs` and can be overridden by setting the `IGNORE` environment variable.\n\nYou can modify the tool's default behavior by setting environment variables in a `.code2clipboard.env` file in your home directory or the current working directory. The current working directory file takes precedence over the home directory's config file\n\nSupported environment variables include:\n\n- `MAX_DEPTH`: Overrides the default maximum directory scanning depth.\n- `PROJECT_DESCRIPTION`: A custom project description to include in the copied content.\n- `MAX_FILE_SIZE`: Overrides the default maximum file size (in KB).\n- `MAX_FILES`: Overrides the default maximum number of files to process.\n- `ADD_IGNORE`: Additional ignore patterns, specified as a CSV string.\n- `OMIT_TREE`: Set to `true` to omit the file tree from the copied content.\n- `EXTENSIONS`: Only copy specific extensions. Specified as a CSV string. `EXTENSIONS=js,ts,jsx,tsx,mjs`\n- `EXTENSIONS_IGNORE`: Ignore specific extensions. Specified as a CSV string. `EXTENSIONS_IGNORE=css,html`\n- `IGNORE`: Overrides the default ignore patterns entirely, specified as a CSV string.\n- `OUTPUT_TO_CONSOLE`: Set to `true` to output the copied content to the console and the clipboard.\n\nHere's an example of what the `.code2clipboard.env` file might look like:\n```\nPROJECT_DESCRIPTION=This project is a sample hello world project.\nMAX_DEPTH=3\nMAX_FILE_SIZE=200\nADD_IGNORE=dist,bin\nEXTENSIONS_IGNORE=md,txt\nOMIT_TREE=true\n```\n\nThere's a sample `.code2clipboard.env.example` file in the root directory that you can use as a template.\n\n## Examples\n\n### Basic Usage\n\nCopy files from the current directory with the default configuration:\n\n```sh\nnode /path/to/code2clipboard.mjs\n```\n\nOr if globally linked:\n\n```sh\ncode2cb\n```\n\n### Specifying a Different Directory\nCopy files from a specific directory:\n```sh\ncode2cb --directory /path/to/your/project\n```\n\n### Limiting Search Depth\nLimit directory scanning to 2 levels deep:\n```sh\ncode2cb -d 2\n```\n\n### Limiting to only JS/TS files\nLimit the file extensions to only javascript/typescript files:\n```sh\ncode2cb -e mjs,cjs,ts,js,jsx,tsx;\ncode2cb --extensions mjs,cjs,ts,js,jsx,tsx;\n```\n\n### Adjusting Maximum File Size\nCopy files that are 50KB or smaller:\n```sh\ncode2cb -s 50\n```\n\n### Changing the maximum number of Files\nCopy a maximum of 50 files:\n```sh\ncode2cb -f 50\n```\n\n### Custom Ignore Patterns\nIgnore `dist` and `test` directories:\n```sh\ncode2cb --ignore dist,test\ncode2cb -i dist,test\n```\n\n### Ignore Specific Extensions\nIgnore markdown and text files:\n```sh\ncode2cb --extensions-ignore md,txt\ncode2cb --ei md,txt\n```\n\n### Omitting the File Tree\n\nCopy files without including the file tree in the clipboard content:\n```sh\ncode2cb --omit-tree\n```\n\n### Comprehensive Example\nCombine multiple options to tailor the copying process. In this example, we're scanning up to 3 directory levels deep in the `/src` directory for files up to 200KB in size and a maximum of 20 files, ignoring only the `node_modules` and `.git` directories and matching only files including the `js, ts, mjs, cjs, jsx` extensions. It also omits the file tree from the copied content:\n```sh\ncode2cb -d 3 -s 200 -f 20 --directory /src --ignore node_modules,.git --extensions js,ts,mjs,cjs,jsx --omit-tree\n```\nShorthand:\n```sh\ncode2cb -d 3 -s 200 -f 20 -d /src --oi node_modules,.git -e js,ts,mjs,cjs,jsx --ot\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffrigby%2Fcode2clipboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffrigby%2Fcode2clipboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffrigby%2Fcode2clipboard/lists"}