Using the —pager Flag
Enable pager mode with the--pager (or -p) flag:
Default Pager
By default, Glow usesless -r as the pager:
-r flag tells less to display ANSI color codes correctly, preserving Glow’s syntax highlighting and styling.
PAGER Environment Variable
Customize the pager by setting thePAGER environment variable:
Using Custom Pagers
You can use any pager that accepts input from stdin:Make sure your pager supports ANSI color codes (like
less -r) to preserve Glow’s styling.Pager vs TUI Mode
Glow offers two modes for viewing markdown:Pager Mode
- Uses external pager program
- Simple, familiar navigation
- Good for single documents
- Activated with
--pager
TUI Mode
- Built-in interactive interface
- File browsing capabilities
- Advanced navigation features
- Activated with
--tui
Mutual Exclusivity
You cannot use both modes simultaneously. Glow will return an error:Pager Implementation
Here’s how Glow executes the pager (main.go:316-329):- Checks the
PAGERenvironment variable - Defaults to
less -rif not set - Splits the command into program and arguments
- Pipes the rendered markdown to the pager
Configuration File
Set pager as the default viewing mode in your configuration file (~/.config/glow/glow.yml):
Examples
Common Pager Options
less options:-r- Display ANSI colors correctly-F- Quit if content fits on one screen-X- Don’t clear screen on exit-S- Disable line wrapping