carbon-now
Create aesthetically pleasing code snippet images
TLDR
Create an image from a file using default settings
Create an image from a text in clipboard using default settings
Create an image from stdin using default settings and copy to the clipboard
Create images interactively for custom settings and optionally save a preset
Create images from a previously saved preset
Start at a specified line of text
End at a specific line of text
Open image in a browser instead of saving
SYNOPSIS
carbon-now [options] [file]
carbon-now [options] < input
PARAMETERS
--help, -h
Display a help message with available options.
--output path, -o path
Specify the directory where the generated image will be saved.
--save-as filename
Define the output image filename, overriding the default.
--language lang, -l lang
Explicitly set the programming language for syntax highlighting (e.g., javascript, python).
--theme theme-name, -t theme-name
Set the code's syntax highlighting theme (e.g., seti, dracula, monokai).
--background color, -b color
Set the background color of the image, typically a hex code like #FF0000 or a named color.
--width pixels
Set the width of the generated image in pixels.
--font-size size
Set the font size of the code in pixels (e.g., 18px).
--window-controls
Display macOS-like window controls on the code image.
--line-numbers
Display line numbers next to the code snippet.
--config path
Load configuration options from a specified JSON file, allowing for presets.
--open-browser
Instead of saving the image, open the generated Carbon image in a web browser.
DESCRIPTION
The carbon-now command, more accurately known as carbon-now-cli, is a command-line interface tool that allows users to generate stylish, shareable images of their source code directly from the terminal. It leverages the popular carbon.now.sh web service, which provides a simple way to create aesthetically pleasing code snippets. Instead of manually visiting the website, pasting code, and downloading the image, carbon-now-cli automates this process.
Users can specify an input file or pipe code directly, along with various customization options such as syntax highlighting theme, programming language, background color, and window style. The generated image is then saved to a specified output directory or the current working directory. It's particularly useful for quickly creating code snippets for presentations, social media, or documentation, streamlining a common developer task.
CAVEATS
The carbon-now command (carbon-now-cli) is not a standard Linux utility; it requires Node.js and npm for installation. It relies on the carbon.now.sh web service, meaning internet connectivity is required for image generation. Advanced features like headless browser rendering (which it uses internally) may require additional system dependencies (e.g., for Puppeteer).
INSTALLATION
To install carbon-now-cli, ensure you have Node.js and npm installed, then use the following command:npm install -g carbon-now-cli
CONFIGURATION FILES
For repetitive tasks or specific styles, users can define presets in a .carbon-now.json
file in their home directory or project root. This file can contain default options, which can then be applied using the --preset name option.
HISTORY
The carbon.now.sh web application gained significant popularity around 2017-2018 for its intuitive interface in creating aesthetically pleasing code snippets. The carbon-now-cli tool was subsequently developed to extend this functionality to the command line, enabling automation and integration into developer workflows without requiring manual browser interaction. It is an open-source project, primarily maintained by the community, leveraging Node.js and Puppeteer for headless browser automation.