-
Notifications
You must be signed in to change notification settings - Fork 329
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
Using lf with cd on exit and show preview images? #1448
Comments
This looks like an unforeseen issue when adding support for sixel previews in #1211, where previews are drawn by using Lines 38 to 44 in dddf437
However I'm not sure how to address this, hopefully someone else might have a better idea. But as a workaround you can try using the old Lines 17 to 30 in 88b3c99
|
OK looks like printing the sixel data to stderr instead of stdout seems to work, while not interfering with command substitution: diff --git a/sixel.go b/sixel.go
index 326187f..7fb3c9f 100644
--- a/sixel.go
+++ b/sixel.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "os"
"strings"
"github.com/gdamore/tcell/v2"
@@ -36,12 +37,12 @@ func (sxs *sixelScreen) showSixels() {
}
// XXX: workaround for bug where quitting lf might leave the terminal in bold
- fmt.Print("\033[0m")
+ fmt.Fprint(os.Stderr, "\033[0m")
- fmt.Print("\0337") // Save cursor position
- fmt.Printf("\033[%d;%dH", sxs.yprev, sxs.xprev) // Move cursor to position
- fmt.Print(*sxs.sixel) //
- fmt.Print("\0338") // Restore cursor position
+ fmt.Fprint(os.Stderr, "\0337") // Save cursor position
+ fmt.Fprintf(os.Stderr, "\033[%d;%dH", sxs.yprev, sxs.xprev) // Move cursor to position
+ fmt.Fprint(os.Stderr, *sxs.sixel) //
+ fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
}
func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) { Would you mind trying out the following branch to see if this approach works for you? https://github.com/joelim-work/lf/tree/fix-sixel-lfcd |
Hey! Thank you so much for taking the time to look into this.
I tried to build the branch you sent but following the build
instructions, I just run the go command and then get nothing. I think I
am not building it correctly, or the binary ended up. I was not able to
build the official release either.
|
It's a standard Go project, so you can just clone the repo and run |
not sure what I did differently, but I managed to get it to compile this
time.
So I built it with `go build` and then ran
```
cd "$(command ./lf -print-last-dir "$@")"
```
But I still have the same issue.
|
That's strange, I tested the changes on my own setup and the sixel previews showed up fine. Hopefully this fix would work for other users too. Did you by any chance check out the correct branch before running Apologies for asking you to go through all this, but I wanted to make sure that this actually works on someone else's setup and not just my own. If you still have trouble I can try tagging some other users to see if they have time to help test. |
Just tested it on mine and it works Previewlfcd.webm |
That's strange, I tested the changes on my own setup and the sixel previews showed up fine. Hopefully this fix would work
for other users too.
Did you by any chance check out the correct branch before running go build? Don't use the master branch on my fork, I
generally keep it synced with the upstream master.
You are right, I was in the wrong branch! Yes, it works with this
change. Thank you very much. :)
|
Thanks for testing it out, I have submitted PR #1451 |
Hi!
I followed the tutorial provided for setting up lf together with image previews. That part works well. What does not work is using it together with lfcd. Instead of showing previews, it prints what I think is the source code for the image.
This is my script
My previewer script is
The text was updated successfully, but these errors were encountered: