A custom preview script for Yazi designed to be used with the piper.yazi or faster-piper.yazi plugins. It renders Markdown files with syntax-highlighted YAML frontmatter using bat, followed by the rendered Markdown body using glow.
- Syntax highlighting for YAML frontmatter (via
bat). - Beautiful Markdown rendering (via
glow). - Automatic terminal width detection.
- Dracula theme integration.
- Proper padding/alignment for terminal display.
Clone this repository to the preferred scripts directory (e.g., ~/scripts):
mkdir -p ~/scripts
git clone https://github.com/yozlog/md-preview-with-frontmatter.git ~/scripts/md-preview-with-frontmatterEnsure the script is executable:
chmod +x ~/scripts/md-preview-with-frontmatter/main.shThis script depends on bat and glow.
Can be installed via Homebrew:
brew install bat glowFor instructions on how to install piper.yazi or faster-piper.yazi, please refer to their respective GitHub pages:
Once the plugins are installed and configured, add the following to yazi.toml:
[plugin]
prepend_preloaders = [
{ url = "*.md", run = 'faster-piper -- ~/scripts/md-preview-with-frontmatter/main.sh "$1" $w' },
]Important
Note on Path: Please update the script path (~/scripts/md-preview-with-frontmatter/main.sh) in the configuration to match the actual storage location.
The script can be used independently in the terminal:
# Usage: ./main.sh <file_path> [terminal_width]
./main.sh my-file.md 80- Theme: The default theme is set to Dracula.
- To change the Markdown theme, edit the
glowcommand inmain.sh(e.g.,-s nord). - To change the Frontmatter theme,
batwill use the global default (configured in~/.config/bat/config) or you can add--themeto thebatcommand inmain.sh.
- To change the Markdown theme, edit the