2

I have a set of lines (item + description) which I want to run through fzf -m. For example:

item1: Some description
item1: Another description
item2: Yet another description

After selection I would like fzf to return the line numbers (e.g. 1 3) instead of the lines themselves because: 1) I don't want to include the description; 2) The items are not unique.

True, I can just prefix the lines with the line numbers first:

1: item1: Some description
2: item1: Another description
3: item2: Yet another description

then extract it later. But I think it would be great if fzf can be instructed to do this. It will make some things easier and open some more possibilities for the tool.

1 Answer 1

2

fzf can already do this with --with-nth to change the presented (and searched-for) line to only some fields of the original line. So we start with:

1: item1: Some description
2: item1: Another description
3: item2: Yet another description

then use:

fzf -d: --with-nth 2..

which means to skip showing the first field (the fields are separated by colon). fzf will then return something like this:

1: item1: Some description
3: item2: Yet another description

from which you can extract the line numbers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .