Carbon Screenshots CLI
Repeatable, easy, and versioned configuration for code screenshots with the Carbon Now CLI.
Carbon is a tool for generating screenshots of code. It allows for quite a bit of customization and sharing that customization is achieved by exporting your config settings. Once you have that config file you can use it with the Carbon Now CLI to easily create code screenshots that consistently follow your configuration.
Once you've finished customizing your settings in the browser, click the gear wheel > Misc > Export config and save the file.
Store your settings
When you use the Carbon Now CLI for the first time it will create a file at
~/carbon-now.json. If that file doesn't exist you can safely create it now. In that JSON file add a key, calling it whatever you like. You'll later use this name in the CLI command. As the value for that key, enter the settings you previously downloaded. You can have multiple config settings and call them individually.
Here's an example config that I use.
Use the CLI with your preset
Documentation. After you've installed the package:
npm i -g carbon-now-cli
You can run a command like the following:
carbon-now dashboard/dashboard.component.html -p material -l ~/Desktop/images
carbon-now [path to file] -p [preset name] -l [path to save images]
The web interface works great, there are plugins for editors like VSCode, an
npx command, and an interactive mode in the CLI. However, I like being able to consistently and easily use the same settings anytime I need to generate an image. This way also makes it easy to save and version control multiple settings and share these settings with the community or other team members if we're trying to be consistent on a project or article.