Overview
Glow can be configured through a YAML configuration file, command-line flags, or environment variables. The configuration system uses Viper for flexible configuration management with automatic precedence handling.The glow config Command
Glow provides a convenient command to edit your configuration:
- Create the config file if it doesn’t exist (with defaults)
- Open it in your
$EDITOR - Save and report the config file location
The
glow config command uses EDITOR environment variable to determine which editor to launch. If not set, it falls back to sensible defaults based on your system.Configuration File Location
Glow searches for configuration files in the following order (first match wins):Platform-specific config directories
Glow uses go-app-paths to determine the default user config directory:
- Linux/BSD:
~/.config/glow/glow.yml - macOS:
~/Library/Application Support/glow/glow.yml - Windows:
%APPDATA%\glow\glow.yml
Default Configuration
When you runglow config for the first time, this default config is created:
Configuration Options
style
Set the rendering style for markdown output.
Type: StringDefault:
"auto" (detects terminal background)Flag:
--style, -s
Options:
auto- Automatically choosedarkorlightbased on terminal backgrounddark- Dark themelight- Light themepink- Pink themedracula- Dracula themenotty- Plain text (used automatically when piping)- Path to custom JSON style file:
/path/to/mystyle.json
If the style is not a built-in name, Glow validates that the file exists at the given path. The path is expanded using
utils.ExpandPath() to support ~ and environment variables.mouse
Enable mouse wheel scrolling in TUI mode.
Type: BooleanDefault:
falseFlag:
--mouse, -m (hidden flag)TUI-mode only: Yes Example:
tea.WithMouseCellMotion() to enable mouse support in the Bubble Tea program (main.go:44-46).
pager
Pipe rendered output through your system pager (like less).
Type: BooleanDefault:
falseFlag:
--pager, -p
Example:
$PAGER environment variable, defaulting to less -r if not set (main.go:316-328).
width
Set the word-wrap width for rendered output.
Type: Integer (unsigned)Default:
0 (auto-detect terminal width, max 120)Flag:
--width, -w
Example:
0- Auto-detect terminal width (capped at 120 for readability)> 0- Wrap at specified width- If terminal width can’t be detected, falls back to 80
all
Show all files including hidden and .gitignored files in TUI mode.
Type: BooleanDefault:
falseFlag:
--all, -aTUI-mode only: Yes Example:
true, Glow uses gitcha.FindAllFilesExcept() instead of gitcha.FindFilesExcept(), showing files that would normally be ignored by Git (ui/ui.go:384-389).
Additional TUI Options
These options are available via flags but not included in the default config file:showLineNumbers
Flag: --line-numbers, -lType: Boolean
Default:
falseTUI-mode only: Yes
preserveNewLines
Flag: --preserve-new-lines, -nType: Boolean
Default:
false
Viper Configuration Binding
Glow uses Viper to bind command-line flags to configuration values. This means:- Config file is loaded first
- Environment variables with
GLOW_prefix override config - Command-line flags override both
Environment Variables
Glow supports environment variable configuration with theGLOW_ prefix:
viper.SetEnvPrefix("glow") and viper.AutomaticEnv()).
Special Environment Variables
Some environment variables are read directly by the TUI Config struct:github.com/caarlos0/env:
Configuration Precedence
Configuration is resolved in this order (highest to lowest priority):- Command-line flags:
glow README.md --style dark --width 100 - Environment variables:
GLOW_STYLE=dark GLOW_WIDTH=100 glow README.md - Config file: Values from
glow.yml - Defaults: Hardcoded defaults in Viper and the code
Example Configurations
Minimal Setup
Power User Setup
CI/CD Environment
Validation
Glow validates configuration during startup (main.go:165-208):Style Validation
Option Conflicts
Troubleshooting
Where is my config file?
Where is my config file?
Run
glow config and it will tell you the location when it saves.Or check these locations:My config isn't being used
My config isn't being used
Check the precedence:
- Are you using command-line flags that override it?
- Do you have environment variables set?
- Is the config file in the right location?
- Is the YAML syntax valid?
Custom style not working
Custom style not working
Ensure:
- The path is absolute or uses
~for home directory - The file exists and is readable
- The JSON is valid Glamour style format
Mouse support not working
Mouse support not working
Note that
--mouse is a hidden flag. Make sure:- Your terminal supports mouse events
- You’re in TUI mode (not CLI mode)
- The flag is properly set in config or via CLI
Related
TUI Mode
Configure TUI-specific options like mouse and all files
CLI Mode
Set defaults for CLI rendering like pager and width