-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Feature Request: Option to hide some fields #102
Comments
Thanks, it's an interesting idea. I can imagine something like: Implementing it, however, could be non-trivial as doing so will make match highlighting (bright green) much more complex, especially in extended-search mode where there can be more than one matched substrings for each item. Maybe we should consider disabling the highlighting when |
At least in my use case, I didn't need to match in the fields that were not visible, I only needed them to appear in the output in the end. If this was the case, I guess it would not be so confusing any more. |
Okay, I see. So we transform the original string and match against it, but return the unmodified string. That makes sense. |
Pushed to |
Hey, that was fast! Thanks. I tried this |
Hmm, are you sure? I can't reproduce:
|
When I use that command, it also works for me:
In fact, I have reduced it to this:
However, it doesn't seem to be a problem in the manual selection in all cases, since:
|
Furthermore, in all the manual selection cases above, if I type nothing, just select the only one match, then it shows Also tried this:
Again, if I don't type anything, but just use arrow keys to select one match, then I get only the visible part. If I filter by typing something, then I get the full string. |
Maybe it's a bug I already fixed in the branch, I force-pushed a couple of times. |
Could it be related to?:
|
Aha, yes, it looks like it's only reproducible on old Rubies, I'll take a look. |
Please pull again and test it. (I'm dealing with the dark side of Ruby :/) |
Works like a charm! Thank you so much! |
Alright, it's finally merged to master. I just needed to write test cases for the problems we ran into. |
I just noticed that if I set the delimiter to something like |
Sorry, my bad, I did not realise that I had to regex-escape the expression passed to |
It's worth noting that the value of |
Ah yes, the help entry could use some clarification. But I felt that it's the only sane way to do it. Imagine the confusion when we do it the other way round, especially in extended-search mode. |
There's always someone who likes the opposite :) John 23 single baseball I would like select all singles who like baseball but only printout their name and age. |
You can post-process the output. e.g. awk, sed. |
Sure I can, and I also can chain fzf calls. There's nearly always more than one way of doing things :) |
@tagwint Yes, and so there's no point of adding the option. It's not like |
I have this file: |
@Bugswriter, I think maybe you could do this?
Demo:
That then shows Is that what you want? |
Oh I can do this. thank you so much for replying the solution. |
Im fighting with this Works, just cant scroll or select anything, on the very rare occasion I do select something, it does not execute. The basic premise of this is to change what the history widget displays then execute on selection. |
This usecase cannot be done with pre- or postprocessors, because we care about the display that fzf gives while selecting, not just the output of the command. In this example, we want to display the names and ages, while searching the other two fields. The output of fzf afterwards can be manipulated by other commands, but the display cannot. Note this would be quite simple if fzf did what the manpage implies, and allows you to separately specify indexes to display and to search:
Based on this, you would expect this to work:
If we enter 'single' then we should see John and Suzi, if we enter 'married' we should see Bob and the person named Single. We specify that we want to search from the third field onwards, but display the first and second field. However, fzf currently filters first on with-nth and then applies the indexes of nth onto the reordered fields - I can't think of any reason to do it that way, it is strictly less powerful than the intuitive reading of the manpage would suggest. |
I answered to the question early on: #102 (comment) |
Suppose we're applying echo foo bar baz qux foo | fzf --with-nth 3,2,4 --nth ..
|
I would contend that the ship has been standing in the harbour in quarantine for three years. I just applied PR1447 and it works exactly as I described above. No need to update documentation. Your example is incorrect, I tried it and all 4 statements about what would match are wrong, presumably you meant to make the --nth actually be some subset, not all fields using '..'; nevertheless I understand where you are taking the point, and you could make the point using my example above. You are saying that you can then pass parameters to fzf which make it behave 'strange' - but, the user put the parameters there, right? If the user explicitly says 'search on fields 3 and 4, but show fields 1 and 2', why do we care whether said user understands what he told fzf to do? |
For what it's worth, my main reason for wanting this is that I have a large preview window which shows the context including the actual line matched and some coloring using grep, so displaying the full line also in the list of matches is duplicate information which just doesn't fit. I am trying to abbreviate that so that I can always see the first part. Currently it shows some part of the match with ellipses on either end of the line, which is not helpful at all. |
You're underestimating the implication of breaking the backward compatibility. Many users of fzf have relied on the current behavior and have written many scripts and we don't want to break them all of a sudden after 7 years.
|
The request
I would like to somehow be able to dissociate what is shown to what is returned. For example, the output of
git --no-pager log --format=oneline --abbrev-commit -n 5
in this repositoryI'd like to be able to show only the commit messages, without the sha, but at the same time, when I choose one, I want the sha to be in the output. So fzf would show me this:
And when I choose the last one, I get this, the full line:
Possible interface
The interface could, for example, be similar to that for limiting the search scope. Only in this case we either choose what to hide, or what to show.
The text was updated successfully, but these errors were encountered: