-
-
Save gabydd/570f0dd5f71dda35241500c18f5d27e3 to your computer and use it in GitHub Desktop.
[keys.normal] | |
C-f = [":new", ":insert-output lf-pick", "split_selection_on_newline", "goto_file", "goto_last_modification", "goto_last_modified_file", ":buffer-close!", ":theme nord", ":theme default"] | |
# replace the default after theme with the theme you use | |
# open 1 with the open command (l and <left> to open) or more with (<space> to select) then quit | |
# all opened files will be opened in helix |
# touch ~/.local/bin/lf-pick | |
# chmod +x ~/.local/bin/lf-pick | |
function lfp(){ | |
local TEMP=$(mktemp) | |
lf -selection-path=$TEMP | |
echo >> $TEMP | |
while read -r line | |
do | |
echo "$line" | |
done < "$TEMP" | |
} | |
lfp |
I updated the fish func a bit, since it doesn't open multiple selected files on my end.
function lf-pick --description 'lf file picker'
if ! type -q lf
echo "lf not installed"
end
set -l TEMP (mktemp)
lf -selection-path=$TEMP
echo >>"$TEMP"
while read -r line
echo "$line"
end <"$TEMP"
end
Also, I set my shell as fish in helix config.toml.
shell = ["fish", "-c"]
It would be useful if anyone happens to know how we can set it up for other terminal emulators like vifm or ranger.
I have this for xplr
, also using fish as shell:
#!/bin/env fish
function xplr-pick --description 'xplr file picker'
if ! type -q xplr
echo "xplr not installed"
end
set -l TEMP (mktemp)
# xplr $TEMP
xplr $PWD
echo >>"$TEMP"
while read -r line
echo "$line"
end <"$TEMP"
end
xplr-pick
But for some reason the redraw is flawed and shows the terminal as it would looked like when launching helix everywhere where empty space is.
@VuiMuich i get this same thing happening non my work MacBook (M2), but it doesn’t happen on my personal intel MacBook.
What are you running? I also tried with different terminal emulators and they all produced the same result on my M2 MacBook.
there is a pr that properly redraws thats waiting on another review helix-editor/helix#6949 , best bet right now to redraw the screen is to preview a theme
@VuiMuich i get this same thing happening non my work MacBook (M2), but it doesn’t happen on my personal intel MacBook.
What are you running? I also tried with different terminal emulators and they all produced the same result on my M2 MacBook.
I am on Manjaro Linux with Alacritty, but also tried wezterm, shell is actually nushell
but my efforts translating the script to nu
was without effort, it seems that some of the redirecting bash and fish are doing with stdout does work to fundamentally different for that to work.
Windows version for PowerShell
config.toml
A-f = [":theme dark_plus"]
C-f = [":new",":insert-output pwsh C:\\Users\\<some-path>\\bin\\lfp.ps1","split_selection_on_newline","goto_file","goto_last_modification","goto_last_modified_file",":buffer-close!",":theme default"]
lfp.ps1
# lf pick (lfp) for helix primarily and lf integration
lf -selection-path=C:\Users\<user>\AppData\Local\Temp\lf.selections
Get-Content $env:TEMP\lf.selections
At least for the Windows terminal it takes 2 key sequences. The terminal goes to the default theme, then use the Alt-F to set it to yours.
also I've faced with the issue when some key bindings does not work after file opening (for example Alt-d) :(
The lf-pick
script is not necessary: :insert-output lf -selection-path=/dev/stdout"
That particular setup breaks Helix mouse scrolling, after coming back from lf
, due to some escape characters used in lf
To avoid that, we may run lf
inside a tmux
popup, It works only if Helix is already inside a tmux session, of course.
lfmux(){
local TEMP=$(mktemp)
tmux popup -h 100% -w 100% -E lf -selection-path=$TEMP
cat $TEMP
}
lfmux
It does open multiple files, without breaking anything.
I was inspired by @webdev23 tmux, but wanted zellij and yazi, so here it is for those interested.
This does not mess up the helix terminal. Note yazi
is not suitable from helix insert-output. Note zellij run
forks and you don't get the selections from the current interaction, so that is why this is broke into two commands.
However, I don't find it an issue to perform two key sequences in helix to open the files. They are also cached, so you don't have to pick agian if you want the same files.
config.toml
A-z = [":run-shell-command zellij run -fc -- yazi --chooser-file /tmp/yazi-chooser-file"]
A-Z = [":new", ":insert-output cat /tmp/yazi-chooser-file", "split_selection_on_newline", "goto_file", "goto_last_modification", "goto_last_modified_file", ":buffer-close!"]
lf -selection-path=/dev/stdout
lf -print-selection
works also. Additionally instead of theme switching :redraw
solves UI re-rendering.
[keys.normal]
C-f = [":new", ":insert-output lf -selection-path=/dev/stdout", "split_selection_on_newline", "goto_file", "goto_last_modification", "goto_last_modified_file", ":buffer-close!", ":redraw"]
Thank you for this.
The best version of this I've found so far (from scratching around in all the various answers), is:
C-f = [":new", ":insert-output lf -print-selection", "split_selection_on_newline", "goto_file", "goto_last_modification", "goto_last_modified_file", ":buffer-close!", ":redraw"]
With no lf-pick
script needed.
It almost works too! But you need to have modified a buffer to get it to open, and it doesn't open from the current location, which is a pain.
I think it's a testament to how much helix needs this functionality that we're all scrabbling around in here, trying desperately to make something work...
Hi this is great! however does every one knows how to open the lf-pick in the current buffer directory?
Thanks for this! for anyone using fish shell, here is it translated as a fish script.