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

How to setup Image Preview on PowerShell on Windows Terminal #1077

Open
Redbeard93 opened this issue Jan 12, 2023 · 4 comments
Open

How to setup Image Preview on PowerShell on Windows Terminal #1077

Redbeard93 opened this issue Jan 12, 2023 · 4 comments

Comments

@Redbeard93
Copy link

Redbeard93 commented Jan 12, 2023

No description provided.

@Ashijo
Copy link

Ashijo commented Feb 2, 2023

On linux we use external packages like ueberzug that use imagemagick to display the image in the terminal. Imagemagick work on powershell but I don't think an equivalent of ueberzug actually exist for PS.
If someone knows one I'm interested too.

@inkfin
Copy link

inkfin commented Dec 17, 2023

There have been some discussions about displaying images in windows terminal link, at current stage it seems like the sixel support is pretty well, and you can use chafa to preview image by setting previewer to chafa.

Here's an example
Screenshot 2023-12-17 185103

@deltoss
Copy link

deltoss commented Mar 18, 2024

Thanks. I've installed & set the previewer to chafa. Works fine for images. But I wanted the preview to also still work with text files, and show the file metadata too.

I ended up creating the below scripts (based on this). Here's the Gist.

  • CustomPreviewer.cmd --> lf should set the previewer to this file. Runs CustomPreviewer.ps1.
  • CustomPreviewer.ps1 --> Contains the actual previewing code, which uses chafa for images. Handles text files & displays file metadata too.

How I did My Setup

  1. Install chafa:

    winget install hpjansson.Chafa --scope machine
  2. Get the above script files and put them anywhere in your system.

  3. Open your lfrc file and add the below line:

    # Custom file previewer
    set previewer "<PathToScriptsFolder>\\CustomPreviewer.cmd"

    E.g:

    set previewer "C:\\ProgramData\\lf\\CustomPreviewer.cmd"
  4. Restart your terminal(s).

Here's the output:

image

image

@ccammack
Copy link

As an alternative, one can also use the browser to preview files.

Cannon demo

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

No branches or pull requests

5 participants