LinuxCommandLibrary

carbon-now

Create aesthetically pleasing code snippet images

TLDR

Create an image from a file using default settings

$ carbon-now [path/to/file]
copy

Create an image from a text in clipboard using default settings
$ carbon-now --from-clipboard
copy

Create an image from stdin using default settings and copy to the clipboard
$ [input] | carbon-now --to-clipboard
copy

Create images interactively for custom settings and optionally save a preset
$ carbon-now [[-i|--interactive]] [path/to/file]
copy

Create images from a previously saved preset
$ carbon-now [[-p|--preset]] [preset] [path/to/file]
copy

Start at a specified line of text
$ carbon-now [[-s|--start]] [line] [path/to/file]
copy

End at a specific line of text
$ carbon-now [[-e|--end]] [line] [path/to/file]
copy

Open image in a browser instead of saving
$ carbon-now --open [path/to/file]
copy

SYNOPSIS

carbon-now [options] [file]

PARAMETERS

-h, --help
    Output usage information.

-v, --version
    Output the version number.

-t, --theme
    Specify the Carbon theme to use (e.g., 'material', 'dracula').

-f, --font
    Specify the font family to use (e.g., 'Fira Code', 'Monoid').

-l, --language
    Specify the programming language for syntax highlighting (e.g., 'javascript', 'python').

-w, --window-controls
    Show window controls (the red, yellow, green dots).

-W, --no-window-controls
    Hide window controls (the red, yellow, green dots).

-s, --shadow
    Show shadow.

-S, --no-shadow
    Hide shadow.

-i, --interactive
    Start interactive mode. Open carbon.now.sh in your browser for further editing

-b, --background
    Set the background color (e.g., '#1A2B34', 'rgba(255, 255, 255, 1)').

-p, --padding
    Set the padding of the code (e.g., '20px', '10px').

-o, --location
    Set the location of the file output (e.g., './output.png', '/tmp/image.png').

[file]
    Path to the source code file. If omitted, reads from standard input.

DESCRIPTION

carbon-now is a command-line tool that simplifies creating aesthetically pleasing images of code snippets. It leverages the Carbon app (carbon.now.sh) allowing users to quickly transform code into visually appealing images suitable for sharing on social media, presentations, or documentation. The tool takes code either from a file or directly from standard input. Options exist to customize the appearance, including theme selection, font adjustments, window controls, and background color. It streamlines the process of creating polished code visualizations, removing the need to manually copy-paste and format code within a web browser. The resulting image can then be easily shared with a focus on visual appeal and readability, improving code communication.
It is written in JavaScript and requires Node.js and npm for installation.

CAVEATS

Requires Node.js and npm to be installed. Relies on the carbon.now.sh web service, so network connectivity is essential. Output quality and accuracy of syntax highlighting depend on the Carbon app.

EXAMPLES

Creating an image from a file:
carbon-now my_script.py

Using a specific theme:
carbon-now -t dracula my_script.py

Specifying the language:
carbon-now -l javascript my_script.js

Reading from standard input:
cat my_script.js | carbon-now -l javascript

Setting a background color:
carbon-now -b '#282c34' my_script.js

Output file location:
carbon-now -o ./output.png my_script.js

INSTALLATION

The recommended way to install carbon-now is through npm:
npm install -g carbon-now-cli

HISTORY

carbon-now was developed to provide a convenient command-line interface for the Carbon code snippet image generator. It streamlines the process, enabling users to quickly generate shareable code images from the terminal. The tool gained popularity among developers and educators seeking to visually enhance their code presentations. It simplifies and automates a common task, reducing reliance on the carbon.now.sh web interface alone.

SEE ALSO

cat(1), echo(1)

Copied to clipboard