@oakoliver/glow
v1.0.1
Published
Terminal markdown reader — zero-dependency TypeScript port of Charmbracelet's Glow
Maintainers
Readme
@oakoliver/glow
Terminal markdown reader — zero-dependency TypeScript port of Charmbracelet's Glow.
Render markdown files beautifully in the terminal, with a full interactive TUI for browsing and filtering markdown files in a directory.
Install
npm install -g @oakoliver/glowOr use as a project dependency:
npm install @oakoliver/glowCLI Usage
# Render a markdown file
glow README.md
# Render from stdin
cat README.md | glow -
# Render from a URL
glow https://raw.githubusercontent.com/charmbracelet/glow/master/README.md
# Render from a GitHub repo
glow github://charmbracelet/glow
# Render from a GitLab repo
glow gitlab://caarlos0/test
# Launch the interactive TUI in the current directory
glow
# Launch the TUI in a specific directory
glow ./docs
# Use a specific style
glow -s dark README.md
# Set word-wrap width
glow -w 80 README.md
# Pipe through a pager
glow -p README.md
# Edit the config file
glow configFlags
| Flag | Short | Description |
|------|-------|-------------|
| --style | -s | Style name or JSON path (default "auto") |
| --width | -w | Word-wrap at width (0 to disable) |
| --pager | -p | Display with system pager |
| --tui | -t | Display with TUI |
| --all | -a | Show system files and directories (TUI only) |
| --line-numbers | -l | Show line numbers (TUI only) |
| --preserve-new-lines | -n | Preserve newlines in the output |
| --mouse | -m | Enable mouse wheel (TUI only) |
| --config | | Config file path |
| --help | -h | Help |
| --version | -v | Version |
Available Styles
auto(default) — automatically detects dark/light terminaldark— dark themelight— light themepink— pink themedracula— Dracula color schemetokyo-night— Tokyo Night color schemenotty— plain output for non-TTY contexts
You can also pass a path to a custom JSON style file.
TUI Keybindings
| Key | Action |
|-----|--------|
| Enter | Open document |
| Esc / h / Backspace | Go back |
| / | Filter files |
| q | Quit |
| r | Refresh files |
| c | Copy to clipboard |
| e | Open in editor |
| ? | Toggle help |
| j / k / Arrow keys | Navigate |
| g / G | Go to top / bottom |
| Ctrl+D / Ctrl+U | Half page down / up |
Library Usage
import {
NewProgram,
StashModel,
PagerModel,
defaultConfig,
removeFrontmatter,
isMarkdownFile,
glamourStyle,
} from '@oakoliver/glow';
// Create a config
const cfg = defaultConfig();
cfg.path = './docs';
// Launch the TUI programmatically
const program = NewProgram(
cfg,
() => new StashModel(cfg),
() => new PagerModel(cfg),
);
await program.run();Configuration
Glow reads its configuration from ~/.config/glow/glow.yml (or $XDG_CONFIG_HOME/glow/glow.yml).
# style name or JSON path (default "auto")
style: "auto"
# mouse support (TUI-mode only)
mouse: false
# use pager to display markdown
pager: false
# word-wrap at width
width: 80
# show all files, including hidden and ignored
all: falseRun glow config to open the config file in your editor.
Part of the Charm Ecosystem Port
This package is part of a complete TypeScript port of the Charmbracelet terminal UI ecosystem:
| Package | npm | Description |
|---------|-----|-------------|
| @oakoliver/lipgloss | @oakoliver/lipgloss | Terminal styling |
| @oakoliver/glamour | @oakoliver/glamour | Markdown rendering |
| @oakoliver/bubbletea | @oakoliver/bubbletea | TUI framework (Elm architecture) |
| @oakoliver/bubbles | @oakoliver/bubbles | TUI components |
| @oakoliver/glow | @oakoliver/glow | Terminal markdown reader |
All packages are zero-dependency, pure TypeScript implementations.
License
MIT - see LICENSE for details.
Original Go implementation by Charmbracelet, licensed under MIT.
