Skip to content

Instantly share code, notes, and snippets.

@lukepighetti
Last active January 13, 2025 18:32
Show Gist options
  • Save lukepighetti/8e4a13db5bdcd68a7d83eee19051ab14 to your computer and use it in GitHub Desktop.
Save lukepighetti/8e4a13db5bdcd68a7d83eee19051ab14 to your computer and use it in GitHub Desktop.
Helix – tree file picker... TODAY?!?
[keys.normal]
C-f = [":new", ":insert-output lf-pick", ":theme default", "select_all", "split_selection_on_newline", "goto_file", "goto_last_modified_file", ":buffer-close!", ":theme tokyonight_storm"]
# touch ~/.local/bin/lf-pick
# chmod +x ~/.local/bin/lf-pick
function lfp(){
local TEMP=$(mktemp)
lf -selection-path=$TEMP
cat $TEMP
}
lfp
@kkonevets
Copy link

lfp(){
  local TEMP=$(mktemp)
  lf -selection-path=$TEMP
  cat $TEMP
}

lfp

worked for me

Yep, thanks, worked for me too on linux

@fgionghi
Copy link

Hei!
I really missed the functionality of open lf in the current directory. With helix itself seems impossibile to get the file path of the current buffer, but this guy is using wezterm to do that: https://quantonganh.com/2023/08/19/turn-helix-into-ide.md

Here what is working for me:

#!/bin/bash

function lfp(){
  status_line=$(wezterm cli get-text | rg -e "(?:NOR\s+|NORMAL|INS\s+|INSERT|SEL\s+|SELECT)\s+[\x{2800}-\x{28FF}]*\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
  filename=$(echo $status_line | awk '{ print $1}')
  local TEMP=$(mktemp)
  lf -selection-path=$TEMP $filename
  cat $TEMP
}

lfp

@Akselmo
Copy link

Akselmo commented Jul 12, 2024

Is there a way to set the current working directory with this as well?

@boydkelly
Copy link

boydkelly commented Jul 24, 2024

i just installed lf for the first time. Looks cool. but how do we set/use keymaps? I notice v selects everything; ENTER gives me a message that it is not mapped. Should this be in ~/.config/lf? What is the basic requirement to get this working?

@goldenratio
Copy link

does this work with yazi?

@ilosrim
Copy link

ilosrim commented Jan 13, 2025

I got this message in ubuntu:

Open file failed: IrregularFile

----------------

no last modified buffer

How can I fix this?!

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