Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Custom Preview Commands #182

Closed
Neurognostic opened this issue Sep 18, 2023 · 4 comments
Closed

[Feature Request] Custom Preview Commands #182

Neurognostic opened this issue Sep 18, 2023 · 4 comments
Milestone

Comments

@Neurognostic
Copy link

Custom Preview Commands

In the preview pane I would like to specify a custom command to output for each file type, possibly overriding the built-in providers. This could be implemented similar to the [open] and [opener] config sections in yazi.toml such as [preview].rules and [previewer].

User configurable previewers should allow any possible preview output, especially text, and would remove the burden of needing to add every edge-case previewer provider to the yazi source.

Handling of external commands that output text could be handled like jq is currently. Though some programs might be blocking and have to finish before they output any lines.

External preview commands for images could either be direct to stdout or need to be written to a cache file first and then the standard image preview behavior could be used. An environment variable such as $IMAGE_CACHE_PATH could be passed to the external command's shell to be used as an argument.

Example Use Cases

  • Toggle between image preview and mediainfo or exiftool textual/informational previews.
  • Toggle between PDF image preview and pdftotext.
  • Pandoc conversions. For example, converting .epub or .docx to markdown and then text preview with syntax highlighting.
  • Add .epub, .doc, .docx previewer either as image preview or converted with pandoc to markdown
  • Microsoft Excel previews with xls2csv
  • Convert fonts to image previews

Related Features

Ability to keybind a menu selection of different [previewer] for the selected file type just like the open --interactive menu for open keybinds.

Having a way to globally toggle between image previewers and text previewers.

@sxyazi
Copy link
Owner

sxyazi commented Sep 19, 2023

Very similar to what I had in mind. The file preview will be integrated into Yazi's plugin system, with Yazi itself retaining only two basic types (ASCII escape codes and images).

I had begun to experiment with it, and the theme system is its first step. I am currently building the necessary underlying abstractions around it.

@jcguu95
Copy link

jcguu95 commented Sep 21, 2023

I would like this feature as well! Thanks for bringing that up.

@sxyazi sxyazi mentioned this issue Sep 23, 2023
40 tasks
@sxyazi sxyazi added this to the v0.1.6 milestone Oct 13, 2023
@sxyazi sxyazi mentioned this issue Nov 24, 2023
1 task
@sxyazi
Copy link
Owner

sxyazi commented Dec 26, 2023

Done by #401.

Here are some examples of built-in plugins: https://github.com/sxyazi/yazi/tree/main/yazi-plugin/preset/plugins

You can try them out on the latest main branch. I'll soon release API documentation for the preloader and previewer at https://yazi-rs.github.io/

@sxyazi sxyazi closed this as completed Dec 26, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants