gokcehan / lf

Terminal file manager
MIT License
7.68k stars 326 forks source link

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

Open Redbeard93 opened 1 year ago

Ashijo commented 1 year ago

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 commented 9 months ago

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 commented 6 months ago

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.

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 commented 2 weeks ago

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

Cannon demo