Skip to content

previewing files

rovr supports a wide range of file types for previewing. the following are the main categories of files that can be previewed:

plain text files are displayed in a text area with syntax highlighting. the language is determined by the file extension. rovr supports a wide range of languages.

mime types are automatically obtained using puremagic to give you a more accurate information of the file’s type. If you additionally have plugins.file_one enabled with plugins.file_one.get_description, you can view extra information, like how many sections, what type, etc.

if you have bat installed and enabled in the rovr config, it will be used to display text files with syntax highlighting for much more languages and theming. uses the same id as text

rovr can display images directly in the terminal. refer to the image previews guide for more details on terminal compatibility and configuration.

when a folder is selected, the preview panel will show a list of the files and folders inside it, allowing you to see the contents without navigating into it.

for archive files (like .zip, .tar.gz, .rar), rovr will display a list of the files and folders contained within the archive.

pdf preview

for pdf files, rovr makes use of poppler. you can also scroll through the pdf with your mouse (scrollbars are unavailable for now) or use your keyboard to navigate it.

rovr makes use of resvg-py to render svg files, so you don’t need resvg installed on your system – it automatically previews the svg file for you without any setup

font preview

for font files (like .ttf, .otf), rovr will display a preview of the font. you can customise the text used in the preview if you want to test extra things

You can change the file type to preview association by modifying the [settings.preview_rules] section in your config.toml

If your mime type is accurate enough (like image/png), you can omit the check and use the mime type only:

[settings.preview_rules]
"image/png" = "image"

the value is any of the default previewers mentioned above in an inline codeblock. Only one is allowed per mime type, but you can add fallbacks with more wildcard mime types

However, in the case of vague mime types like application/gzip, if you want to preview .svgz files as an svg instead of a failed archive file, you can use the following rule:

[settings.preview_rules."application/(x-)?gzip"]
default = "archive"
extensions = { svgz = "resvg" }

In the above example, we are telling rovr that for files with mime type application/gzip and application/x-gzip, to use archive by default, except if the file ends with .svgz, and in that case, use the svg renderer

The full syntax for the preview rules is as follows:

[settings.preview_rules."mime/type"]
default = "previewer_name"
extensions = { "ext1" = "previewer_name1", "ext2" = "previewer_name2" }

You can also create your own previewers for any file type. For example, if you want to preview .md files using glow, you can add the following to your config.toml:

[settings.previewers]
"glow" = { command = ["glow", "--style", "dark", "%h"], file = "__stdout__", type = "text" }
[settings.preview_rules."text/plain"]
default = "text"
extensions = { "md" = "glow" }

rovr will now use glow to preview .md files instead of bat (or rovr’s built-in text highlighter). This preview is also cached, so if you have a large markdown file, it will not be re-rendered every time you open it. You can also use the --style option to change the theme of the preview.

For images, you can have type = "image" for your custom previewer. For example, if you want to preview .html files using helium (or any chromium browsers), you can add the following to your config.toml:

[settings.previewers.helium]
command = ["helium", "--headless", "--no-first-run", "--disable-gpu", "--user-data-dir=%tmpdir", "--screenshot=%file", "%h"]
file = "%temp.png"
type = "image"
[settings.preview_rules."text/html"]
default = "text"
extensions = { html = "helium", htm = "helium" }
[settings.preview_rules."text/plain"]
default = "text"
extensions = { html = "helium", htm = "helium" }

%file is the path configured by file, so helium writes the PNG that rovr reads. %temp keeps the source extension; %temp.png uses .png instead. This also works with other output extensions, provided your previewer can produce and rovr can display them. %tmpdir gives each run its own temporary browser profile and is removed when the command finishes.

A launcher-supplied --user-data-dir can override the temporary profile above. On Windows with scoop, it will force a profile directory, you should instead direct it to the underlying chrome.exe path

The %h is the path to the file being previewed. The command will be run with the file path as an argument, and the output will be displayed in the preview panel.


The %temp is the path to a temporary file that will be created for the previewer to write to. You can modify the file extension by including it in the %temp variable, like %temp.png. The temporary file will be deleted after the preview is displayed.

The full syntax for the custom previewers is as follows:

[settings.previewers."previewer_name"]
command = ["command", "arg1", "arg2", "%h"]
file = "%temp(.ext) | __stdout__ | __stderr__ | /path/to/file"
type = "text | image | pdf"
on_nonzero_exit = "details" # or any default available previewers mentioned above

Supported Expansions:

  • %h - path to the file being previewed
  • %rh - realpath to file being previewed
  • %nh - name of file being previewed
  • %rnh - realpath name of file being previewed
  • %cwd - current working directory
  • %rcwd - realpath to current working directory
  • %temp - path to a temporary file that will be created for the previewer to write to.
    You can include a file extension in the variable, like %temp.png. The temporary file will be deleted after the preview is displayed.
  • %tmpdir - path to a temporary directory that will be created for the previewer to write to.
    The temporary directory will be deleted after the preview is displayed.

Helium and Glow are mentioned above, here is a few more previewers that you can use:

  • libreoffice: for previewing office documents like .docx, .xlsx, .pptx Paste the following python script somewhere accessible and add it to your config.toml as a previewer:
import subprocess, os, sys
to_preview, outfile = sys.argv
write_to = os.path.dirname(outfile)
proc = subprocess.run(
["libreoffice", "--headless", "--convert-to", "pdf",
to_preview, "--outdir", write_to],
capture_output=True,
check=False,
)
if proc.returncode != 0:
# because libreoffice prints errors to stdout
print(proc.stdout.decode())
exit(proc.returncode)
else:
replace(
path.join(write_to, os.path.splitext(os.path.basename(to_preview))[0] + ".pdf"),
outfile,
)

Then add the following to your config.toml:

[settings.previewers.libreoffice]
command = ["python", "/path/to/libre.py", "%h", "%file"]
file = "%temp.pdf"
type = "pdf"
[settings.preview_rules]
"application/(vnd\\.)?openxmlformats-officedocument.*" = "libreoffice"
"application/oasis.opendocument.*" = "libreoffice"
"application/ms-*" = "libreoffice"
"application/msword" = "libreoffice"
  • pixelorama: for previewing .pxo files, frames arent supported, its just a static image previewer
[settings.previewers.pixelorama]
command = ['pixelorama', '--headless', '--quit', '--', '%h', '--export', '--output', '%file']
file = "%temp.png"
type = "image"
[settings.preview_rules."application/zip"]
default = "archive"
extensions = { pxo = "pixelorama" }