-
PremiseI know a file manager got merged a while ago, however my release (on nixpkgs unstable) does not have it and I would prefer using yazi within Helix to interact with files anyway. Attempted SolutionThis video explains how to use LazyGit inside Helix. The video maps "C-g" = [":new", ":insert-output lazygit", ":buffer-close!", ":redraw"]Which then allows you to press I tried to do the same with yazi, with little success. I expected "C-f" = [":new", ":insert-output yazi --chooser-file=/dev/stdout", ":buffer-close!", ":redraw"]to work, however when I press |
Beta Was this translation helpful? Give feedback.
Replies: 14 comments 21 replies
-
|
Hi, Yazi author here 👋 I added support for using Yazi directly in Helix (without needing Zellij or tmux) in sxyazi/yazi#2461, which only requires a keybinding: [keys.normal]
C-y = [
':sh rm -f /tmp/unique-file',
':insert-output yazi "%{buffer_name}" --chooser-file=/tmp/unique-file',
':sh printf "\x1b[?1049h\x1b[?2004h" > /dev/tty',
':open %sh{cat /tmp/unique-file}',
':redraw',
]See sxyazi/yazi#2461 for more info! Demoscreenshot-002279.mp4Bonus: You can even preview images and videos within Helix!screenshot-002284.mp4 |
Beta Was this translation helpful? Give feedback.
-
|
works like a charm |
Beta Was this translation helpful? Give feedback.
-
|
I am not using nix. I am on maxOs. Here is my config entry e = [ that said, when I press the "space+e" to open my yazi instance and select a file in yazi, I am seeing two files are being created and they are opened in two new buffers. They are "%sh{cat" and "unique-file}" (without the quotes- they are mine). Can you please help me out what I might be doing wrong here? I just copied the code from above. |
Beta Was this translation helpful? Give feedback.
-
|
It would be nice that it worked when selecting multiple files. For example, in the shell (nushell in my case) i can do I also tryed escaping the paths but it didnt work. |
Beta Was this translation helpful? Give feedback.
-
|
Using the configuration provided in the answer, Yazi opens inside Helix, but when I select a file, Helix just opens It seems there is a race condition between the command that writes the file path and the command that reads from the file: Helix tries to read /tmp/unique-file before Yazi has written to it. As a result, Helix opens the chooser file itself, not the actual file I selected. How can I fix this? |
Beta Was this translation helpful? Give feedback.
-
|
If using zellij, you can do the following which even supports opening multiple files at once: Yazi config (opener): This is a general technique which I also use for lazygit. Here I used floating panes, but zellij allows many other configurations (sidebar, new tab etc). |
Beta Was this translation helpful? Give feedback.
-
|
If the above solution doesn't work, then this will work: |
Beta Was this translation helpful? Give feedback.
-
|
None of the above solutions seem to work in Windows. Is there a way to use Yazi with Helix in Windows? |
Beta Was this translation helpful? Give feedback.
-
|
I neglected this thread! If you're using Nushell as your shell in Windows, you can use this setup to use Yazi. Make sure Nushell is set as your shell in your config.toml [editor]
shell = ["nu", "-c"]Then you can add these lines which replicate the PowerShell functionality: [keys.normal]
C-y = [
':sh rm --force C:\temp\unique-file',
':insert-output yazi.exe %{buffer_name} --chooser-file=C:\temp\unique-file',
':open %sh{open --raw C:\temp\unique-file}',
":redraw",
":reload-all"
]Note, as far as I've been able to tell, this is still just as susceptible to the redraw problem once Helix is closed, at least on Windows 11 running Windows Terminal. |
Beta Was this translation helpful? Give feedback.
-
|
For anyone who works on Next and sometimes has "(" or ")" in their path the @sxyazi solution does not work. The following handles this corner case. C-y = [
':sh rm -f /tmp/unique-file',
":insert-output yazi '%{buffer_name}' --chooser-file=/tmp/unique-file",
':insert-output echo "\x1b[?1049h\x1b[?2004h" > /dev/tty',
':open %sh{cat /tmp/unique-file}',
':redraw',
] |
Beta Was this translation helpful? Give feedback.
-
|
If someone here is also wondering how to get the current working directory to change to the folder which the file you opened is in, here you go: C-f = [
':sh rm -f /tmp/unique-file',
':sh rm -f /tmp/unique-cwd-file',
":insert-output yazi --chooser-file=/tmp/unique-file --cwd-file=/tmp/unique-cwd-file",
':insert-output echo "\x1b[?1049h\x1b[?2004h" > /dev/tty',
':open %sh{cat /tmp/unique-file}',
':cd %sh{cat /tmp/unique-cwd-file}',
':redraw',
] |
Beta Was this translation helpful? Give feedback.
-
|
FYI, @linsui mentioned in sxyazi/yazi#3496 that using :sh printf "\x1b[?1049h\x1b[?2004h" > /dev/ttyinstead of :insert-output echo "\x1b[?1049h\x1b[?2004h" > /dev/ttycan fix the problem where the screen is not properly cleared after exiting Helix - I have updated it to #12934 (comment), hope this helps! Also, I opened #15059 to propose a dedicated command for launching external interactive TUI apps, so we can avoid all the hacks and glitches to get a better integration. |
Beta Was this translation helpful? Give feedback.
-
|
For Windows 11, I tried Yazi [ 💚 ] within Helix [ 🚀 ], the command below works for me. I tried [running in the same terminal instance], but I faced lots of issues, like
In this method, Yazi will run within a separate window, but it works fine without any problem. If you are using CMD, then use this command [when CMD needs to maximize on startup] If there is an issue of adding [^C] when exiting using the close button, then you can use the line below, I wanted to use Windows Terminal with Fullscreen mode using CMD command. |
Beta Was this translation helpful? Give feedback.
-
|
Using this with Ghostty on macOS 14.8.3 worked great, except that after using |
Beta Was this translation helpful? Give feedback.
Hi, Yazi author here 👋
I added support for using Yazi directly in Helix (without needing Zellij or tmux) in sxyazi/yazi#2461, which only requires a keybinding:
See sxyazi/yazi#2461 for more info!
Demo
screenshot-002279.mp4
Bonus: You can even preview images and videos within Helix!
screenshot-002284.mp4