Skip to content

Configuration

Chris W edited this page Dec 9, 2024 · 2 revisions

CLI Configuration

This guide covers the configuration options available for the Goshot CLI. Configuration can be managed through command-line flags or a configuration file.

Configuration File

Goshot looks for a configuration file in the following locations:

  • $HOME/.config/goshot/config.yaml (Unix)
  • %APPDATA%\goshot\config.yaml (Windows)

The configuration file uses YAML format and supports all the same options as the command-line flags. Here's an example configuration:

# Input/Output settings
io:
  # Default output filename for screenshots. Supports templating with the following variables and functions:
  #
  # Template Functions:
  # - {{ formatDate "format" }} - Format current date/time (Go time format, e.g. "2006-01-02_15-04-05")
  #
  # File Variables (from input file):
  # - {{ .Filename }} - Input filename with extension (e.g., "code.go", "clipboard", or "stdin")
  # - {{ .FileBase }} - Input filename without extension (e.g., "code" or "goshot")
  # - {{ .FileExt }} - Input file extension with dot (e.g., ".go" or "")
  # - {{ .FileDir }} - Directory containing the input file (or cwd for clipboard/stdin)
  #
  # System Variables:
  # - {{ .User }} - Current username
  # - {{ .Host }} - Hostname
  # - {{ .Path }} - Current working directory
  output_file: "code.png"
  # Automatically copy the generated image to clipboard
  copy_to_clipboard: false

# Appearance settings
appearance:
  # Window chrome style: "mac", "windows", or "gnome"
  window_chrome: "mac"
  # Theme for window controls (light/dark, empty for auto-detection)
  chrome_theme_name: ""
  # Use light mode for syntax highlighting
  light_mode: false
  # Syntax highlighting theme (e.g., "ayu-dark", "monokai", "github")
  theme: "ayu-dark"
  # Font family for code rendering
  font: "JetBrainsMonoNerdFont"
  # Line height multiplier for code text
  line_height: 1.0
  
  # Background settings
  background:
    # Background color in hex format
    color: "#ABB8C3"
    # Optional background image
    image:
      # Path to image file
      source: ""
      # Image fit mode: "contain", "cover", "fill", "stretch", "tile"
      fit: "cover"
    # Gradient background settings
    gradient:
      # Gradient type: "linear", "radial", "angular", "diamond", "spiral", "square", "star"
      type: ""
      # List of color stops in format ["color;position", ...] (position: 0-100)
      stops: ["#232323;0", "#383838;100"]
      # Angle in degrees for linear gradients
      angle: 45
      # Center point for radial/angular gradients
      center:
        x: 0.5  # 0.0-1.0
        y: 0.5  # 0.0-1.0
      # Intensity of the gradient effect (1-10)
      intensity: 5
  
  # Drop shadow settings
  shadow:
    # Shadow color in hex format with alpha
    color: "#00000033"
    # Blur radius in pixels
    blur_radius: 0.0
    # Shadow spread in pixels
    spread: 0.0
    # Shadow offset
    offset:
      x: 0.0  # Horizontal offset in pixels
      y: 0.0  # Vertical offset in pixels
  
  # Show line numbers in code
  line_numbers: true
  # Corner radius for the entire image
  corner_radius: 10.0
  
  # Window appearance settings
  window:
    # Show window control buttons
    controls: true
    # Custom window title (empty for default)
    title: ""
    # Corner radius for window chrome
    corner_radius: 10.0
  
  # Layout and padding settings
  layout:
    # Padding between lines of code
    line_padding: 2
    # Tab width in spaces
    tab_width: 4
    # Minimum width of the output image (0 for auto)
    min_width: 0
    # Maximum width of the output image (0 for no limit)
    max_width: 0
    # Padding settings
    padding:
      horizontal: 40  # Left and right padding
      vertical: 40    # Top and bottom padding
      code:
        top: 0      # Additional top padding for code
        bottom: 0   # Additional bottom padding for code
        left: 0     # Additional left padding for code
        right: 0    # Additional right padding for code
      line_numbers: 4  # Padding between line numbers and code

## Configuration Groups

### Input/Output Options
- `io.output_file`: Output file path with template support
- `io.copy_to_clipboard`: Copy result to clipboard

### Appearance Options
- `appearance.window_chrome`: Window chrome style (mac, windows, gnome)
- `appearance.chrome_theme_name`: Theme for the window chrome
- `appearance.light_mode`: Use light mode
- `appearance.theme`: Syntax highlighting theme
- `appearance.font`: Font to use
- `appearance.line_height`: Line height multiplier
- `appearance.line_numbers`: Show line numbers
- `appearance.corner_radius`: Corner radius for the image

### Background Options
- `appearance.background.color`: Background color in hex format
- `appearance.background.image.source`: Background image path
- `appearance.background.image.fit`: Background image fit mode
- `appearance.background.gradient.*`: Gradient settings (type, stops, angle, etc.)

### Window Options
- `appearance.window.controls`: Show window controls
- `appearance.window.title`: Custom window title
- `appearance.window.corner_radius`: Corner radius for window chrome

### Shadow Options
- `appearance.shadow.color`: Shadow color with alpha
- `appearance.shadow.blur_radius`: Shadow blur radius
- `appearance.shadow.spread`: Shadow spread distance
- `appearance.shadow.offset.x`: Horizontal shadow offset
- `appearance.shadow.offset.y`: Vertical shadow offset

### Layout Options
- `appearance.layout.line_padding`: Padding between lines
- `appearance.layout.tab_width`: Number of spaces per tab
- `appearance.layout.min_width`: Minimum width of output
- `appearance.layout.max_width`: Maximum width of output
- `appearance.layout.padding.*`: Various padding settings

Clone this wiki locally