Skip to content

Add view_mode config option to open files with system default viewer#10

Merged
kooler merged 3 commits intokooler:mainfrom
turnipy:feature/system-default-viewer
Apr 20, 2026
Merged

Add view_mode config option to open files with system default viewer#10
kooler merged 3 commits intokooler:mainfrom
turnipy:feature/system-default-viewer

Conversation

@turnipy
Copy link
Copy Markdown
Contributor

@turnipy turnipy commented Apr 6, 2026

Summary

  • Adds a view_mode setting under [behavior] in config.toml with two values:
    • "pager" (default) — existing behaviour, opens in $PAGER/less
    • "system" — opens the file using the OS default application (xdg-open on Linux, open on macOS, explorer on Windows)
  • Fully backward-compatible: the default is "pager" so nothing changes unless the user opts in

Motivation

The F3 (View) key currently always opens files in a terminal pager, which is useless — or even broken — for binary and non-text formats like images, videos, PDFs, or office documents. With view_mode = "system", pressing F3 hands the file off to whatever the OS has registered for that extension, so an image opens in an image viewer, a PDF in a PDF reader, and so on, without leaving mdc.

Usage:

[behavior]
view_mode = "system"

Notes

This feature was developed with assistance from Claude Code (Anthropic's AI coding tool). I found it genuinely useful for my own workflow but wanted to be transparent — feel free to reject this PR if AI-assisted contributions are a concern for the project.

🤖 Generated with Claude Code

turnipy and others added 3 commits April 6, 2026 12:18
Adds a `view_mode` setting under `[behavior]` in config.toml. When set
to `"system"`, pressing F3 (View) opens the file using the OS default
application (xdg-open on Linux, open on macOS, explorer on Windows)
instead of the terminal pager. Useful for images, videos, PDFs, and
other binary/non-text formats. Defaults to `"pager"` for unchanged
backward-compatible behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fileActionCmd's "preview" case called viewFileCmd directly, bypassing
the view_mode config. Now routes through openSystemDefaultCmd when
view_mode = "system", consistent with the F3 View behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kooler kooler merged commit 2319953 into kooler:main Apr 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants