-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Feat] Allow adjustment of output formatting #4319
Comments
Have you tested |
I have, it does not change the quote wrapping between accept and echoing the output. |
Can you test again? $ echo foo bar | fzf --accept-nth 2
bar |
Apologies I wasn't clear in which part produces quotes, I am specifically talking about using
This is always formatted differently to the output of In the below examples, selecting a value with enter will yield the first two fields formatted without quotes, and selecting with f1 or f2 will yield the first and last fields with different kinds of quotation. In a single call of fzf the logical option is to never use
On Linux this isn't a problem as the formatting of I would argue that all of the outputs should be formatted consistently, and that that format should be without quotes for all options as it is when using fzf on Linux. This may impact legacy implementations on Windows however hence the feature request instead of a bug report. I should have included all of this detail in the initial post, I realise it is not as clear as it was in my head. |
We need to clarify a few things. A placeholder expression is designed to be evaluated to a quoted string, so that it can be safely passed as an argument to an external program. It was first introduced to be used with fzf --preview 'cat {}' However, it looks like Another thing.
FWIW, this strategy will not work on non-Windows binaries since 0.53.0.
The output of echo test | fzf --bind 'enter:execute(echo {1})+abort' | wc
# test
# 0 0 0 You're supposed to use echo test | fzf --bind "enter:become(echo {1})" | wc
1 1 5
You can specify a template if you need multiple placeholders. echo foo bar baz | fzf --accept-nth '[template example] {1} // {1,3,2} // {1} {3} {2} // {-1}'
# [template example] foo // foo bazbar // foo baz bar // baz
As noted above, each placeholder expression is "always" quoted and properly escaped to be passed as an argument on Linux. Say you have a file named fzf --preview 'cat {}' becomes Manual quoting doesn't work either. fzf --preview "cat '{}'" becomes fzf also does quoting on Windows, but using a different set of rules. Lines 142 to 165 in ba6d1b8
Coming up with the rule was painful due to many edge cases, but I guess it's still not perfect. See #2609 and #3651. |
Checklist
man fzf
)Output of
fzf --version
0.60.3 (0012183)
OS
Shell
Problem / Steps to reproduce
Right now using {n} outputs the field in double quotes. In nix I can easily trim this but in Windows this becomes a hassle and requires post processing of the fzf output outside of the fzf call itself.
Could an option be added to define what the wrapping character is? Or just a toggle to remove it?
Example:
This is a minimum example to showcase the output difference, I am aware that the function in the example is no different to the regular fzf output.
The text was updated successfully, but these errors were encountered: