Skip to content

Conversation

@d3m3t3r
Copy link

@d3m3t3r d3m3t3r commented May 27, 2024

Re-publishing my old change (#111...not quite sure why I closed it back then) adding support for splitting the input to fields where certain field can be used for searching and another field for the output of the command.

    -d, --delimiter=DELIM      Use DELIM to split the line to fields (default ':')
    -f, --field=NUM                Use field NUM for searching (default is the whole line)
    -F, --output-field=NUM   Use field NUM for output (default is the whole line)

For instance, cat /etc/passwd | fzy -d: -f1 -F6 will fuzzy-search the usernames and then print the home directory of the chosen user.

@eilefsen
Copy link

This is excellent! It works great for my use-case (printing an index instead of the matched string).

I was able to merge it with master locally and everything appears to still be fine.
Would love to see this get merged!

@eilefsen
Copy link

Hmm... It appears this does not work with the -e option.

-f works as expected, but -F does not. the output does at least follow the result of -f

@eilefsen
Copy link

eilefsen commented Mar 16, 2025

After familiarizing myself with the code, i discovered the source of the bug i mentioned above. You forgot to replace choices_get in fzy.c the same way you did in tty_interface.c.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants