{"id":13406209,"url":"https://github.com/mixn/carbon-now-cli","last_synced_at":"2025-05-12T13:08:35.206Z","repository":{"id":37390787,"uuid":"139448014","full_name":"mixn/carbon-now-cli","owner":"mixn","description":"🎨 Beautiful images of your code — from right inside your terminal.","archived":false,"fork":false,"pushed_at":"2025-05-01T18:25:52.000Z","size":23627,"stargazers_count":5879,"open_issues_count":2,"forks_count":122,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-05-01T19:34:37.923Z","etag":null,"topics":["cli","cli-app","cli-application","cli-command","cli-tool","cli-utilities","cli-utility","command-line","node","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mixn.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","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,"zenodo":null}},"created_at":"2018-07-02T13:33:05.000Z","updated_at":"2025-05-01T18:25:50.000Z","dependencies_parsed_at":"2022-07-13T12:20:36.057Z","dependency_job_id":"97691a32-0ac1-4208-aa25-e74403dabca7","html_url":"https://github.com/mixn/carbon-now-cli","commit_stats":{"total_commits":344,"total_committers":6,"mean_commits":"57.333333333333336","dds":"0.12790697674418605","last_synced_commit":"d0fe032911be48effcb699469badf860043acfea"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixn%2Fcarbon-now-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixn%2Fcarbon-now-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixn%2Fcarbon-now-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixn%2Fcarbon-now-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixn","download_url":"https://codeload.github.com/mixn/carbon-now-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745160,"owners_count":21957317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli","cli-app","cli-application","cli-command","cli-tool","cli-utilities","cli-utility","command-line","node","nodejs"],"created_at":"2024-07-30T19:02:24.173Z","updated_at":"2025-05-12T13:08:35.162Z","avatar_url":"https://github.com/mixn.png","language":"TypeScript","readme":"# [![Carbon CLI](static/banner.png)](https://github.com/mixn/carbon-now-cli)\n\n\u003e 🎨 Beautiful images of your code — from right inside your terminal.\n\n[![Build Status](https://github.com/mixn/carbon-now-cli/actions/workflows/tests.yml/badge.svg)](https://github.com/mixn/carbon-now-cli/actions) [![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Featured in awesome-nodejs](https://awesome.re/badge.svg)](https://github.com/sindresorhus/awesome-nodejs#command-line-apps) [![Twitter](https://img.shields.io/twitter/follow/mixn?style=social)](https://twitter.com/mixn) [![Stargazers](https://img.shields.io/github/stars/mixn/carbon-now-cli?label=Stars\u0026style=social)](https://github.com/mixn/carbon-now-cli/stargazers/) [![Maintenance](https://img.shields.io/maintenance/yes/2030?label=Maintained\u0026color=limegreen)](https://github.com/mixn/carbon-now-cli/graphs/commit-activity) [![Requirements](https://img.shields.io/node/v/carbon-now-cli?label=Node\u0026color=limegreen)](https://img.shields.io/node/v/carbon-now-cli) [![MIT license](https://img.shields.io/github/license/mixn/carbon-now-cli?label=License\u0026color=limegreen)](https://github.com/mixn/carbon-now-cli/blob/master/license)\n\n## Table of Contents\n\n- [Description](#description)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Presets](#presets)\n- [License](#license)\n- [Examples](#examples)\n\n## Description\n\n`carbon-now-cli` brings the power of [Carbon](https://carbon.now.sh/) directly to your terminal. ⚡️\n\nGenerate beautiful images of your code with a single command.\n\nWant to customize *everything* before generating the image? Run it in `--interactive` mode. 💅\n\n![Basic example](static/demo.gif)\n\n## Features\n\n- 🖼 Downloads the real, high-quality image (no DOM screenshots)\n- ✨ Detects file type automatically\n- 🗂 Supports all languages \u0026amp; [covers extra ground](https://github.com/mixn/carbon-now-cli/blob/master/src/helpers/cli/extensions-map.helper.ts)\n- ⚡️ [Interactive mode](#fully-customized) via `--interactive`\n- 🎒 [Presets](#presets) via `--preset` to save and re-use your favorite settings\n- 🖱 [Selective processing](#selective) via `--start` and `--end`\n- 📎 [Copies image to clipboard](#copying-to-clipboard) via `--to-clipboard` (cross-OS 😱)\n- 📚 Accepts [file, `stdin`, or clipboard content](#input-sources) as input\n- 🖋️ Supports [custom theme colors](#custom-theme-colors)\n- 🥞 Supports concurrency for easier batch processing\n- 👀 Saves to [given location](#full-example) or [opens in browser](#full-example) for manual finish\n- 🐶 Displays image directly in supported terminals\n- 🌈 Supports different export types (`png`, `svg`)\n- 📏 Supports different resolutions (`1x`, `2x`, `4x`)\n- ⏱ Reports each step and therefore shortens the wait\n- ✅ Heavily tested\n- ⛏ Actively maintained\n- 🧺 …[and](https://github.com/mixn/carbon-now-cli/issues/50) [more](https://github.com/mixn/carbon-now-cli/issues/70)!\n\n## Installation\n\n### Bun\n\n```\nbun i -g carbon-now-cli\n```\n\n### pnpm\n\n```\npnpm i -g carbon-now-cli\n```\n\n### npx\n\n```\nnpx carbon-now-cli \u003cfile\u003e\n```\n\n### npm\n\n```\nnpm i -g carbon-now-cli\n```\n\n### yarn\n\n```\nyarn global add carbon-now-cli\n```\n\n#### Requirements\n\n[![Requirements](https://img.shields.io/node/v/carbon-now-cli?label=Node\u0026color=limegreen)](https://img.shields.io/node/v/carbon-now-cli)\n\n## Usage\n\n```\nBeautiful images of your code — from right inside your terminal.\n\nUsage\n  $ carbon-now \u003cfile\u003e\n  $ pbpaste | carbon-now\n  $ carbon-now --from-clipboard\n\nOptions\n  --start, -s          Starting line of input\n  --end, -e            Ending line of input\n  --interactive, -i    Interactive mode\n  --preset, -p         Apply an existing preset\n  --save-to            Image save location, default: cwd\n  --save-as            Image name without extension, default: original-hash\n  --from-clipboard     Read input from clipboard instead of file\n  --to-clipboard       Copy image to clipboard instead of saving\n  --open-in-browser    Open in browser instead of saving\n  --config             Use a different, local config (read-only)\n  --settings           Override specific settings for this run\n  --disable-headless   Run Playwright in headful mode\n  --engine             Use different rendering engine, default: `chromium`\n                       Options: `chromium`, `firefox`, `webkit`\n  --skip-display       Don’t display the image in the terminal\n\nExamples\n  See: https://github.com/mixn/carbon-now-cli#examples\n```\n\n## Presets\n\n### Creating a Preset\n\nRunning the `carbon-now` command generates a `~/.carbon-now.json` config file.\n\nPresets are stored in this file and consist of [available settings](#settings). You can create presets either manually or automatically via the `--interactive` flag. When prompted, answer the following:\n\n![Presets 1](static/presets-1.png)\n\nFor example, naming the preset `presentation` will add it to `~/.carbon-now.json` like this:\n\n```ts\n{\n  \"latest-preset\": {\n    // Equal to `presentation` below\n  },\n  \"presentation\": {\n    \"theme\": \"base16-light\",\n    \"backgroundColor\": \"white\",\n    \"windowTheme\": \"none\",\n    \"windowControls\": true,\n    \"fontFamily\": \"Space Mono\",\n    \"fontSize\": \"18px\",\n    \"lineNumbers\": false,\n    \"firstLineNumber\": 1,\n    \"selectedLines\": \"*\",\n    \"dropShadow\": false,\n    \"dropShadowOffsetY\": \"20px\",\n    \"dropShadowBlurRadius\": \"68px\",\n    \"widthAdjustment\": true,\n    \"width\": \"20000px\",\n    \"lineHeight\": \"140%\",\n    \"paddingVertical\": \"35px\",\n    \"paddingHorizontal\": \"35px\",\n    \"squaredImage\": false,\n    \"watermark\": false,\n    \"exportSize\": \"2x\",\n    \"type\": \"png\"\n  }\n}\n```\n\n`latest-preset` will be overwritten after each run, while `presentation` remains until manually deleted.\n\n### Using a saved preset\n\nTo use a saved preset, simply run:\n\n```\ncarbon-now _unfold.js --preset \u003cname-of-preset\u003e\n```\n\nIf the preset or `~/.carbon-now.json` does not exist, `carbon-now-cli` will fall back to the [default settings](https://github.com/mixn/carbon-now-cli/blob/master/src/config/cli/default-settings.config.ts) and be [smart about the rest](#re-using-settings).\n\n**Result**:\n\n![Presets 1](static/presets-2.png)\n\n### Settings\n\n```ts\ninterface CarbonCLIPresetInterface {\n  backgroundColor: string;\n  dropShadow: boolean;\n  dropShadowBlurRadius: string;\n  dropShadowOffsetY: string;\n  exportSize: '1x' | '2x' | '4x';\n  firstLineNumber: number;\n  fontFamily: CarbonFontFamilyType;\n  fontSize: string;\n  lineHeight: string;\n  lineNumbers: boolean;\n  paddingHorizontal: string;\n  paddingVertical: string;\n  selectedLines: string; // All: \"*\"; Lines 3-6: \"3,4,5,6\", etc.\n  squaredImage: boolean;\n  theme: CarbonThemeType;\n  type: 'png' | 'svg';\n  watermark: boolean;\n  widthAdjustment: boolean;\n  windowControls: boolean;\n  windowTheme: 'none' | 'sharp' | 'bw';\n  custom?: CarbonThemeHighlightsInterface;\n  width?: string;\n  // Below are detected automatically, and not persisted as keys\n  language?: string;\n  titleBar?: string;\n}\n```\n\nAlso see [`CarbonFontFamilyType`](https://github.com/mixn/carbon-now-cli/blob/master/src/types/carbon/global.d.ts), [`CarbonThemeType`](https://github.com/mixn/carbon-now-cli/blob/master/src/types/carbon/global.d.ts) \u0026 [`CarbonThemeHighlightsInterface`](https://github.com/mixn/carbon-now-cli/blob/master/src/types/carbon/global.d.ts)\n\n### Re-using settings\n\n#### *It just works.* ™\n\n`carbon-now` automatically reuses settings from previous runs, so you don’t need to worry about manually reconfiguring them.\n\n![Presets 3](static/presets-3.png)\n\n\u003c!--\nCurrently, the precedence of settings is as follows:\n\n[Default settings](https://github.com/mixn/carbon-now-cli/blob/master/src/config/cli/default-settings.config.ts) `\u003c` Preset `\u003c` `--interactive` `\u003c` `--settings`\n--\u003e\n\n### Custom theme colors\n\nFrom `v2.0`, `carbon-now-cli` supports custom theme colors for detailed styling. Define a `custom` key inside a preset that complies to the following type:\n\n```ts\ninterface CarbonThemeHighlightsInterface {\n  background?: string;\n  text?: string;\n  variable?: string;\n  variable2?: string;\n  variable3?: string;\n  attribute?: string;\n  definition?: string;\n  keyword?: string;\n  operator?: string;\n  property?: string;\n  number?: string;\n  string?: string;\n  comment?: string;\n  meta?: string;\n  tag?: string;\n}\n```\n\nExample  `~/.carbon-now.json` with custom theme colors:\n\n```ts\n{\n  \"hacker\": {\n    \"backgroundColor\": \"rgba(0, 255, 0, 1)\",\n    \"windowTheme\": \"bw\",\n    \"windowControls\": true,\n    \"fontFamily\": \"Anonymous Pro\",\n    \"fontSize\": \"18px\",\n    \"lineNumbers\": false,\n    \"firstLineNumber\": 1,\n    \"dropShadow\": false,\n    \"selectedLines\": \"*\",\n    \"dropShadowOffsetY\": \"20px\",\n    \"dropShadowBlurRadius\": \"68px\",\n    \"widthAdjustment\": true,\n    \"lineHeight\": \"133%\",\n    \"paddingVertical\": \"30px\",\n    \"paddingHorizontal\": \"30px\",\n    \"squaredImage\": false,\n    \"watermark\": false,\n    \"exportSize\": \"2x\",\n    \"type\": \"png\",\n    \"custom\": {\n      \"background\": \"rgba(0, 0, 0, 1)\",\n      \"text\": \"rgba(0, 255, 0, 1)\",\n      \"variable\": \"rgba(0, 255, 0, 1)\",\n      \"variable2\": \"rgba(0, 255, 0, 1)\",\n      \"attribute\": \"rgba(0, 255, 0, 1)\",\n      \"definition\": \"rgba(0, 255, 0, 1)\",\n      \"keyword\": \"rgba(0, 255, 0, 1)\",\n      \"operator\": \"rgba(0, 255, 0, 1)\",\n      \"property\": \"rgba(0, 255, 0, 1)\",\n      \"number\": \"rgba(0, 255, 0, 1)\",\n      \"string\": \"rgba(0, 255, 0, 1)\",\n      \"comment\": \"rgba(0, 255, 0, 1)\",\n      \"meta\": \"rgba(0, 255, 0, 1)\",\n      \"tag\": \"rgba(0, 255, 0, 1)\"\n    }\n  }\n}\n```\n\n```\ncarbon-now _unfold.js --preset hacker\n```\n\n### Result:\n\n![Presets 3](static/presets-4.png)\n\n### Limitations\n\nPlease note that custom theme colors aren’t applied with `--open-in-browser` because they aren’t query string parameters but instead use `localStorage`, which is solely set inside the Playwright instance.\n\n## Local configs\n\nUse the `--config` flag for local configuration files. This is helpful for sharing presets across users in a project.\n\n```\ncarbon-now _unfold.js --config local-config.json --preset dark\n```\n\nLocal configs are **read-only** and differ from `~/.carbon-now.json` in that:\n\n1. `local-config.json` won’t be created if it doesn’t exist.\n2. `latest-preset` is not written to `local-config.json`.\n\n## Examples\n\nAssuming you have a file `_unfold.js` with this content:\n\n```javascript\n// Example from https://carbon.now.sh/\nconst unfold = (f, seed) =\u003e {\n  const go = (f, seed, acc) =\u003e {\n    const res = f(seed)\n    return res ? go(f, res[1], acc.concat([res[0]])) : acc\n  }\n  return go(f, seed, [])\n};\n```\n\n### Basic\n\n```\ncarbon-now _unfold.js\n```\n\nUses [default settings](https://github.com/mixn/carbon-now-cli/blob/master/src/config/cli/default-settings.config.ts) and saves the image as `.png` in your `cwd`.\n\n**Result**:\n\n![Basic example](static/example-1.png)\n\n### Fully customized\n\n```\ncarbon-now _unfold.js --interactive\n```\n\nLaunches interactive mode to customize every aspect, like theme, `font-family`, `padding`, etc.\n\n**Input**:\n\n![Example 2, Input](static/example-2-1.png)\n\n**Result**:\n\n![Example 2, Output](static/example-2-2.png)\n\n### Selective\n\n```\ncarbon-now _unfold.js --start 3 --end 6\n```\n\nGenerates an image for lines `3` to `6`. Will throw an error if `--start` \u003e `--end`.\n\n**Result**:\n\n![Example 3](static/example-3.png)\n\n### Copying to clipboard\n\n![Copying to Clipboard](static/clipboard-demo.gif)\n\nCopies the image to clipboard instead of saving it. Requires `xclip` on Linux.\n\n```\ncarbon-now _unfold.js --to-clipboard\n```\n\n#### Linux\n\n[`xclip`](https://linux.die.net/man/1/xclip) is required. Install with\n\n```\nsudo apt-get install xclip\n```\n\n#### Windows \u0026amp; macOS\n\n*It just works.* ™\n\n### Input Sources\n\nIn addition to files, input from `stdin` or the clipboard is also supported.\n\n#### `stdin`\n\n```\npbpaste | carbon-now\necho '\u003ch1\u003eHi\u003c/h1\u003e' | carbon-now\n```\n\n#### Clipboard\n\n```\ncarbon-now --from-clipboard\n```\n\n### Overrides\n\nYou can override settings on a per-run basis.\n\n```\ncarbon-now _unfold.js --preset presentation --settings '{\"theme\": \"nord\", \"titleBar\": \"custom-title.js\"}'\n```\n\n**Result**:\n\n![Example 4](static/example-4.png)\n\n### Full Example\n\n```\ncarbon-now _unfold.js --start 3 --end 6 --save-to ~/Desktop --save-as example-23 --interactive\n```\n\nSaves an image of lines `3`-`6` to `~/Desktop/example-23.png` with custom settings.\n\nTo preview in the browser instead of saving, do\n\n```\ncarbon-now _unfold.js --start 3 --end 6 --interactive --open-in-browser\n```\n\n## License\n\nMIT © [Miloš Sutanovac](https://twitter.com/mixn)\n","funding_links":[],"categories":["Packages","JavaScript","TypeScript","Images","包","awesome CLI 🔧","Applications","Terminal","Command-line apps","Awesome Tools","cli","目录","编程"],"sub_categories":["Command-line apps","Emoji","命令行程序","开发者必备 🚀","Directory Navigation","Apps and Tools","EduTech","命令行应用","命令行工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixn%2Fcarbon-now-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixn%2Fcarbon-now-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixn%2Fcarbon-now-cli/lists"}