Skip to content

watzon/goshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

163 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Goshot

Go Reference Go Report Card License

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.

✨ Features

  • 🎨 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

Installation

# CLI
go install github.com/watzon/goshot/cmd/goshot@latest

# Library
go get github.com/watzon/goshot

Packages 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

Packaging status

CLI

# 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 -la

Run goshot --help for the full flag list, and goshot themes, goshot fonts, or goshot languages to see what's available.

Configuration

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: 12

Library

The 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.

Packages

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

License

This project is licensed under the MIT License β€” see the LICENSE file for details.

Packages

 
 
 

Contributors