codeshot

command module
v0.0.0-...-7544a40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 17 Imported by: 0

README

codeshot

A CLI tool to turn your code into beautiful, shareable images—right from the command line.
Perfect for docs, tweets, slides, bug reports, and more.

[!NOTE] Try codeshot with nvim! codeshot.nvim


✨ Features

  • Syntax highlighting for 100+ languages (Chroma-powered)
  • Customizable themes (Dracula, Gruvbox, OneDark, and more)
  • Modern fonts (bundled FiraCode or any TTF)
  • Gorgeous output: rounded corners, shadow, macOS-style bar, true color
  • Easy clipboard copy (if supported)
  • Direct integration with editors and scripts (supports piping, files, or raw text)
  • Lightning fast—written in Go

🚀 Quick Start

1. Install

Requires Go 1.21+ (for go install method).
Prebuilt binaries coming soon!

go install github.com/flothjl/codeshot@latest

Make sure $GOBIN (usually ~/go/bin) is in your $PATH.


2. Basic Usage
codeshot --file main.go

This will save a codeshot.png in your current directory, highlighting the code.


3. Advanced Usage

Input from STDIN:

cat main.go | codeshot --lang go --theme dracula --out main.png

Select a theme:

codeshot --file app.py --theme gruvbox

Set output file or copy to clipboard:

codeshot --file main.go --out /tmp/myshot.png
codeshot --file main.go           # (default: screenshot.png)

(Clipboard copy coming soon! On macOS/Linux)

Change font:

codeshot --file foo.rs --font "/path/to/JetBrainsMono-Regular.ttf"

4. All Command-Line Flags
Flag Description Example
--file Path to input code file --file main.go
--text Raw code as an argument --text "print(42)"
--lang Filetype/language (e.g., go, python) --lang go
--theme Chroma style (default: dracula) --theme gruvbox
--font Path to TTF font --font ./fonts/FiraCode-Regular.ttf
--out Output file path --out /tmp/code.png

🎨 Supported Themes

  • Dracula
  • Gruvbox
  • OneDark
  • Nord
  • Solarized Dark/Light
  • (and many more! See Chroma Styles)

👾 Supported Languages

Anything Chroma supports—Go, Python, JS, Rust, HTML, Bash, C, Lua, and over 100 more.


🧩 Integration Examples

  • With Neovim (codeshot.nvim):
    Visually select code, run :Codeshot or <leader>cs, screenshot is auto-created!

  • With VSCode:
    Add a custom task or keybinding to call codeshot on the current file.

  • With Shell Scripts:

    for f in *.go; do codeshot --file "$f" --out "${f%.go}.png"; done
    

💡 Tips

  • Use high-res fonts for better screenshots.
  • Combine with imgcat in iTerm2 to display images inline!
  • Works great in CI/CD for visual code diffs.

🛠️ Building from Source

git clone https://github.com/flothjl/codeshot.git
cd codeshot/cmd/codeshot
go build -o codeshot

🤝 Contributing

Pull requests welcome!
Open an issue to suggest features or report bugs.


📜 License

MIT


👋 Author

Joshua Floth
github.com/flothjl


Star this repo if you find it useful!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL