Goshot is a Go library and CLI for creating beautiful screenshots of code and terminal output, with syntax highlighting, window chrome, and rich backgrounds. Similar to Carbon and Silicon.
- π¨ Syntax highlighting with hundreds of themes (chroma)
- π₯ Terminal output rendering with full ANSI color support
- πΌ Window chrome styles: macOS, Windows 11, GNOME, KDE Breeze
- π Backgrounds: solid colors, seven gradient types, and images
- π Color emoji in code and terminal output (uses the system emoji font)
- πΆ Automatic redaction of secrets (API keys, tokens, passwords)
- π§ Drop shadows, rounded corners, blur effects
- π€ Embedded fonts plus system font discovery
- πΎ PNG, JPEG, and BMP export; clipboard and stdout output
- π Run a command and screenshot its output in one step
# CLI
go install github.com/watzon/goshot/cmd/goshot@latest
# Library
go get github.com/watzon/goshotPackages are also available for Arch (AUR) and Ubuntu (PPA):
yay -S goshot-bin # Arch
sudo add-apt-repository ppa:watzon/goshot # Ubuntu
sudo apt install goshot# Screenshot a file
goshot main.go -o main.png
# Read from stdin, write to the clipboard
cat main.go | goshot -c
# Pick a theme, chrome, and background
goshot main.go -t catppuccin-mocha -C gnome -b '#1e1e2e'
# Gradient background with highlighted lines
goshot main.go --gradient-type linear \
--gradient-stops '#4158D0;0' --gradient-stops '#C850C0;100' \
--highlight-lines 10..14
# Redact secrets before sharing
goshot config.go --redact --redact-style blur
# Run a command and screenshot its output
goshot exec -A -p -- go test ./...
# Blend the title bar into the content for a seamless window
goshot exec -A -p --title-bar-color auto -- ls -laRun goshot --help for the full flag list, and goshot themes, goshot fonts, or goshot languages to see what's available.
Defaults for any flag can be set in ~/.config/goshot/config.yaml as a flat map of flag names to values. Flags given on the command line always win.
theme: catppuccin-mocha
chrome: mac
background: "#1e1e2e"
corner-radius: 12The library is a small pipeline: content (code or terminal output) is rendered to an image, wrapped in chrome, and placed on a background.
package main
import (
"image/color"
"log"
"github.com/watzon/goshot"
"github.com/watzon/goshot/background"
"github.com/watzon/goshot/chrome"
"github.com/watzon/goshot/code"
)
func main() {
err := goshot.New().
WithContent(code.New(`fmt.Println("Hello, goshot!")`).
WithLanguage("go").
WithTheme("dracula")).
WithChrome(chrome.Mac().WithTitle("hello.go").Dark()).
WithBackground(background.Gradient(background.LinearGradient,
background.Stop{Color: color.RGBA{26, 27, 38, 255}, Position: 0},
background.Stop{Color: color.RGBA{40, 42, 54, 255}, Position: 1},
).
WithAngle(45).
WithPadding(60).
WithCornerRadius(10).
WithShadow(background.NewShadow().WithBlur(20).WithOffset(0, 8))).
Save("hello.png")
if err != nil {
log.Fatal(err)
}
}Terminal output works the same way with the term package:
content := term.New(ansiOutput).
WithTheme("catppuccin-mocha").
WithAutoSize()
img, err := goshot.New().
WithContent(content).
WithChrome(chrome.Mac().Dark().WithTitleBarMatchingContent()).
Image()WithTitleBarMatchingContent blends the title bar into the content's
background; WithTitleBarColor and WithTitleTextColor set explicit
colors. Emoji β including flags, skin tones, and ZWJ sequences like
π¨βπ©βπ§βπ¦ β render automatically through the system emoji font (Apple
Color Emoji, Noto Color Emoji, or any font with "emoji" in its filename).
See examples/ for runnable programs covering gradients, terminal rendering, and redaction.
| Package | Purpose |
|---|---|
goshot |
The canvas pipeline and image export |
code |
Syntax-highlighted code rendering |
term |
Terminal output rendering (ANSI escapes, 256 colors) |
chrome |
Window decorations (mac, windows, gnome, breeze) |
background |
Solid, gradient, and image backdrops |
fonts |
Embedded and system font loading |
This project is licensed under the MIT License β see the LICENSE file for details.
