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

MacOS imag-preview #44

Closed
Jac-Zac opened this issue Feb 27, 2021 · 57 comments
Closed

MacOS imag-preview #44

Jac-Zac opened this issue Feb 27, 2021 · 57 comments

Comments

@Jac-Zac
Copy link
Contributor

Jac-Zac commented Feb 27, 2021

Just to make you aware of this, preview of thumbnails doesn't work on macOS. The script download the images were it should, but it doesn't show them. It looks like the problem has to do with Überzug. I also tried to run fontpreview-ueberzug which won't work either. But I might also be wrong so if other people have mac they might be helpful. I also tried to used Überzug to preview images in ranger and It doesn't work. In ranger they use a preview for that works with iTerm terminal emulator. An example is imgcat

@westofer
Copy link
Contributor

can you post the output of ueberzug version?

mine is 18.1.9

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented Feb 28, 2021

ueberzug version

Same... Does it work for you ? @westofer

@westofer
Copy link
Contributor

westofer commented Feb 28, 2021

yes it works, are you using fish by any chance? becuase it doesn't work in fish for me

@Jac-Zac

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented Feb 28, 2021

yes it works, are you using fish by any chance? becuase it doesn't work in fish for me

@Jac-Zac

I’m using zsh maybe we can have a discord server and talk there instead of just messaging ? @westofer

@westofer
Copy link
Contributor

sure @Jac-Zac

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented Feb 28, 2021

https://discord.gg/FNym2zpK This is the discord server if we find helpful we might also expand it in the future and add it to README.md
@westofer

@khuei
Copy link

khuei commented Mar 3, 2021

Ueberzug relied on X11 so it wouldn't work in system that doesn't use X11

I know it's late but this might be helpful to some people who have this issue

@pystardust
Copy link
Owner

Yes people on wayland are also having this issue. If anybody knows a terminal viewer that work on wayland + mac do let us know.

@cybardev
Copy link
Contributor

cybardev commented Mar 3, 2021

Yes people on wayland are also having this issue. If anybody knows a terminal viewer that work on wayland + mac do let us know.

Would w3m work?

@tinywrkb
Copy link

tinywrkb commented Mar 3, 2021

@pystardust Ranger file manager has iTerm2 support for image previews, so maybe look at what it's doing. I don't have a Mac but it worked for me with Alacritty when pulling in the graphics PR that adds iTerm2 protocol & libsixel (though it looks like it won't be merged as it is).
Ranger also has support for the image protocol of Kitty, and Kitty is also cross-platform.

@khuei
Copy link

khuei commented Mar 4, 2021

I also like the way neofetch provides different image preview options for the user to choose from. I understand it would take a long time to implement, but it would be a neat and cool feature.

@dimitarvp
Copy link

My ueberzug is also at 18.1.9 and I update ytfzf daily with a cron job. I am on the latest macOS (11.2.3 as of today) and for me image previews don't work either. Tried inside iTerm2 and Alacritty, no dice in both.

I am not very keen on using a non-upstream version of Alacritty for now but might be willing to try pulling the above-mentioned graphics PR.

Is there anything us the macOS users can do to have the images previewed in our terminals?

@cybardev
Copy link
Contributor

cybardev commented Mar 21, 2021

Is there anything us the macOS users can do to have the images previewed in our terminals?

Try to change the code in ytfzf a bit to use iTerm2's own image renderer.

Tbh even I'd like if there were options like neofetch - I'd use my kitty terminal's internal renderer.

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented Mar 21, 2021

I think we should do it like you said using iTerm's own image viewer like they have done here. This is the iTerm page. But you can't just use the imgcat script because fzf will just output the long string. If anybody has some ideas on what we can do I would be wiling to work together to try to solve it maybe on discord

@khuei
Copy link

khuei commented Mar 22, 2021

I will try to implement different image viewers similar to neofetch, so user can choose whichever one they like. However, I think we should try to get w3m working as an alternative to ueberzug, since w3m should work on all system.

@pystardust
Copy link
Owner

Yes I have tried w3mimg, it works well only with some terminals(urxvt)
Run this scirpt in a directory with images, do not give it any arguments.
You would need to give the path to your w3mimgdisplay binary that would be usually in /usr/lib/w3m/ depending on your distro. I have copied mine to my ~/.bin/ here

#!/bin/sh

path_to_w3mimg=~/.bin/w3mimgdisplay

showimage () {
	printf '%b\n3;\n4\n' "0;1;20;20;$((FZF_PREVIEW_COLUMNS *55/10));$((FZF_PREVIEW_COLUMNS *55/10));;;;;$1"  | "$path_to_w3mimg" &>/dev/null 
}

if [ "$#" -eq 1 ]; then
	showimage "$1"
else
	fzf --preview "sh $0 {}" --preview-window "left"
fi

@pystardust
Copy link
Owner

If this seems fine, then we could add this feature in ytfzf

@khuei
Copy link

khuei commented Mar 26, 2021

Can someone with macOS test this script?

@dimitarvp
Copy link

@Z5483 Which script exactly? The one that uses w3mimgdisplay? I am not even sure how to install it on a Mac.

@khuei
Copy link

khuei commented Mar 26, 2021

yes, the w3mdisplay script @pystardust posted few days ago.

#!​/bin/sh​

path_to_w3mimg=​~​/.bin/w3mimgdisplay

​showimage​ () {
        ​printf​ ​'​%b\n3;\n4\n​'​ ​"​0;1;20;20;​$((​FZF_PREVIEW_COLUMNS ​*55/10))​;​$((​FZF_PREVIEW_COLUMNS ​*55/10))​;;;;;​$1"​  ​|​ ​"$path_to_w3mimg"​ ​&>​/dev/null 
}

​if​ [ ​"$#"​ ​-eq​ 1 ]​;​ ​then​
        showimage ​"$1"​
​else​
        fzf --preview ​"​sh ​$0​ {}​"​ --preview-window ​"​left​"​
​fi​

copy fhe above into a file and make the file executable using chmod +x. Then, you should be able to run the script.

@dimitarvp
Copy link

dimitarvp commented Mar 26, 2021

I can't run that script because I have no ~​/.bin/w3mimgdisplay file. Doing brew search w3mimgdisplay didn't yield any results either. Any quick pointers how to install that binary? A quick search on the net doesn't show it as a standalone package for Mac.

@westofer
Copy link
Contributor

install w3m

@dimitarvp
Copy link

@westofer Installed it via brew install w3m but still no w3mimgdisplay binary in its directory tree -- or anywhere in $PATH. Only w3m and w3mman.

@westofer
Copy link
Contributor

westofer commented Mar 26, 2021

find / -name 'w3mimgdisplay'

mine was in /usr/lib/w3m/w3mimgdisplay

@dimitarvp
Copy link

Already did that. It's nowhere to be found. I don't think the homebrew package includes it.

@khuei
Copy link

khuei commented Mar 26, 2021

it might be related to this issue tats/w3m#95

@dimitarvp
Copy link

dimitarvp commented Mar 26, 2021

OK, cloned, compiled with the right options, changed the path in the above script, ran it in both iTerm2 and Alacritty (in a directory that has images in it), moved with the keyboard arrows until I got to an image in the file list -- nothing appears on the left. Also waited for fc-cache to finish (it spiked for several seconds) just to make sure.

I am seeing a blank black pane on the left. It has borders but no content.

Also pressed ENTER when selecting an image -- I only get the image file name as an output of the script.

I am new to w3m. Is there a way to test image showing in the terminal in isolation like with imgcat? Just running w3mimgdisplay image.jpeg does nothing.

@dimitarvp
Copy link

Another thing. Somewhere along the whole stuff an XQuartz installer popped up in the background which I didn't notice. I went through its installation and logged out and back in as the installer requested.

Results are the same. Maybe w3m has to be reconfigured and recompiled now that XQuartz is in place?

@khuei
Copy link

khuei commented Mar 26, 2021

Maybe w3m has to be reconfigured and recompiled now that XQuartz is in place?

This is outside of my knowledge since I'm not familiar with macOS. I think unlikely that you will have to recompile w3m since it does not depend neither XQuartz or Xlib.

ran it in both iTerm2 and Alacritty (in a directory that has images in it), moved with the keyboard arrows until I got to an image in the file list -- nothing appears on the left

I will take at a look at the w3mdisplay script this weekend.

@khuei
Copy link

khuei commented Mar 30, 2021

I can confirm that the w3mdisplay script results in the image flickers then disappears

@pystardust
Copy link
Owner

Could someone with a mac try using iTerms image viewer and make a script that would display an image given as input, with the give height and width at a given coordinate

@cheemeng
Copy link

cheemeng commented Apr 24, 2021

Instead of specifically relying on iTerm's imgcat (you can't even reposition the image, and there might be users of other terminals too such as Kitty or Wez's), perhaps you could take a look at timg?

It plays nicely with fzf too using the --preview parameter (might help you simplify maintenance of your menu system), heck you can even have timg output thumbnails into files instead of display, and simply cat the files out later.

@Euro20179
Copy link
Collaborator

Euro20179 commented May 19, 2021

it is hard to implement image viewers that don't use ascii characters because of the way fzf's preview works, it basically only accepts ascii, the reason ueberzug works is because it's it's own window, w3m could possibly work, but whenever you try to use it the image is only on the screen for about .2 seconds.

viewers i tried that didn't work (all of which are proper image viewers)

  1. kitty/icat
  2. tycat
  3. w3m
  4. lsix/sixel

until something gets implemented for all OS/display servers, i'd recommend chafa as it seems to be the best, but it's your choice

@Euro20179
Copy link
Collaborator

I have implemented w3m, see my latest comments on #64.

@arisolt
Copy link

arisolt commented Apr 3, 2023

With kitty support broken/removed and sixel not supported by fzf is there any option left for Mac users to preview images in the terminal?

@jstkdng
Copy link

jstkdng commented May 2, 2023

Hey everyone, I have been developing this project, https://github.com/jstkdng/ueberzugpp, it is a drop in replacement for ueberzug but with aditional features such as sixel, kitty and iterm2 support. @Euro20179 has kindly added support for my project in ytfzf development branch and so far under linux all 4 outputs work (x11, kitty, sixel, iterm2).
U++ should also work in MacOS but I have not being able to test it since I don't own any apple devices. I'd be happy to help if someone is willing to test U++ in MacOS and finally close this issue.

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

Trying to run the development branch to test it on mac gives me this error:

./ytfzf       
./ytfzf: line 3109: syntax error near unexpected token `;;'
./ytfzf: line 3109: `		youtube-dl) ${ytdl_path} -F "$1" ;;'```

@Euro20179
Copy link
Collaborator

Euro20179 commented May 4, 2023

What is the output of ls -l /usr/bin/sh (im interested in what it's linking to)

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

I get this:

ls -l /usr/bin/sh 
lsd: /usr/bin/sh: No such file or directory (os error 2).```
In general though I use zsh:

echo $SHELL
/bin/zsh
``

Indeed by running: dash ytfzf it works

@Euro20179
Copy link
Collaborator

Euro20179 commented May 4, 2023

Oh interesting, since /usr/bin/sh doesn't exist, it's probably running ytfzf with zsh which is unsupported.
Actually, ytfzf is using /usr/bin/env sh, i'm assuming the env path doesn't exist, i'll have to fix that.

I'll look into that later, for now run dash ytfzf -t -T iterm2 search, and see if the thumbnails work.

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

Mmmm maybe it is just my problem and for some reason my sh is still liking to zsh and it should link to something like dash or bash. If I run it as you said it runs but the previewer doesn't work since it still try to run with zsh. If I change the shabang from sh to dash I get it to work though

@Euro20179
Copy link
Collaborator

Euro20179 commented May 4, 2023

Mmmm maybe it is just my problem and for some reason my sh is still liking to zsh

Nah, ls said that /usr/bin/sh doesn't exist in the first place, it's not linking to anything.

ytfzf uses /usr/bin/env sh as the shebang, try changing it to /bin/env sh, if that works I'll probably change the shebang to that.

And just to confirm, thumbnails do work with iterm2?

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

Oky but: /usr/bin/env does and when I run /usr/bin/env sh I'm quite sure I get a zsh shell so that is the problem. As I said using /usr/bin/env dash I get it to work on the other hand this path doesn't exist: /bin/env

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

About the thumbnails not really and I'm not really sure what was the porblem since I get this:
image
and it seems to be stuck

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

I have also tried with: ueberzug I do not get any error but I get the same behavior

@Euro20179
Copy link
Collaborator

Oky but: /usr/bin/env does and when I run /usr/bin/env sh I'm quite sure I get a zsh shell so that is the problem. As I said using /usr/bin/env dash I get it to work on the other hand this path doesn't exist: /bin/env

Oh, nvm then.

I have also tried with: ueberzug I do not get any error but I get the same behavior

Ueberzug wont work, linux only,

apparently iterm2 is not in the newest version of ueberzugpp, so it needs to be compiled manually if your up for that, if you're not up for it, it's all good.

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 4, 2023

What exactly should I do ? btw I meant that I have tried with ueberzugcpp not ueberzug since I have that in my path with the name ueberzug

@Euro20179
Copy link
Collaborator

Euro20179 commented May 4, 2023

in my path with the name ueberzug

ytfzf checks specifically if you have ueberzugpp as a binary, so I would create a link called ueberzugpp to ueberzug, make sure you have ueberzugpp saved as ueberzug and ueberzugpp, as they're both used in ytfzf (I may change this later).

Then run ytfzf -t -T iterm2 search

If that doesn't work you could try the following:

ueberzugpp needs to be compiled manually (until iterm2 gets put into a release), as instructed on the ueberzugpp readme, make sure to disable x11 support.

Put the binary, and a copy named ueberzug somewhere in path

run ytfzf -t -T iterm2 search in the iterm2 terminal, theoretically images should show up

@jstkdng
Copy link

jstkdng commented May 4, 2023

X11 support should work in theory since MacOS has xquartz, the terminal also has to run through xquartz though. The same reason x11 works in wayland, only if the terminal is also running through xwayland.

@jstkdng
Copy link

jstkdng commented May 5, 2023

Managed to get a macos vm running and pushed a temporary fix for U++, turns out MacOS doesn't support procfs and uses different directories for pseudo-terminals, gonna have to work around that. It works at least.

image

Sometimes this error appears though.

image

@Euro20179
Copy link
Collaborator

It works at least.

Nice!

As for the error, it might've just failed to download the image.

@Jac-Zac
Copy link
Contributor Author

Jac-Zac commented May 5, 2023

Ohhh sorry, It also works for me, but yesterday was very late and I made a symlink to ueberzugcpp instad of ueberzugpp my fault 🤦

@Euro20179
Copy link
Collaborator

I made a symlink to ueberzugcpp instad of ueberzugpp my fault

Lol, glad it works though!

@jstkdng
Copy link

jstkdng commented May 5, 2023

nice, I also fixed the proc issue. Now I think some more testing could be done by other users? I'll try to create a homebrew package.

@jstkdng
Copy link

jstkdng commented May 7, 2023

I have created a release with iterm2 and macos support. I've also created a homebrew script but it will take some time before it is included in homebrew-core.
I guess this could be closed unless there are other issues.

@Euro20179
Copy link
Collaborator

I guess this could be closed unless there are other issues.

Once I release 2.6.0 I will close this (assuming there are no other issues).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests