Search content, complete with file name #1151
-
I want to search files for content or symbols and turn the command into a complete command, but with the file name for the selected result instead of the full result. Is the best way to do that: require("fzf-lua").fzf_exec({"foo", "bar"}, {
complete = function(selected, opts, line, col)
----------------------------
-- Parse selection to strip it of everything but file name
----------------------------
-- then:
local newline = line:sub(1, col) .. selected[1]
return newline, #newline - 1
end
}) edit: I've marked the answer that works for me (on Windows), but for Linux the solution in these comments might be cleaner: |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I found this, which is probably a better description of what I want: https://superuser.com/questions/1632357/how-do-i-configure-fzf-to-return-only-a-specific-field-of-the-selected-line. ps -fe | fzf --bind 'enter:become(echo {2})' ps -fe | fzf -m --bind 'enter:become(echo {+2})' I will see if I can get working with fzf-lua's options. |
Beta Was this translation helpful? Give feedback.
-
You can either pass these directly using |
Beta Was this translation helpful? Give feedback.
-
❯ ls | fzf --bind 'enter:become(echo {2})'
become action is not supported on Windows Welp. Back to parsing the result in the complete function then. edit: btw, thank you so much for getting fzflua working on Windows. Been wishing for that for a long time. |
Beta Was this translation helpful? Give feedback.
path.file_to_entry