Skip to content

Expand multiple items, manipulating each item first #4153

Answered by LangLangBart
rieje asked this question in Q&A
Discussion options

You must be logged in to vote

You could try to take advantage of fd's --format flag by adding the listed values twice: once as {/.}, the basename without the file extension, and once as {}, the normal path, separated by a character you like. In the example below, the Record separator \x1e1 2 is used.

Then, pipe the output into fzf, set the delimiter to your chosen character, and control what is displayed with --with-nth. After this, you can use {1} or {2} to perform the desired action.

fd -a --format $'{/.}\x1e{}' | fzf --delimiter '\x1e' --with-nth 1 --preview 'echo {+2}'

Footnotes

  1. ASCII Table -- Nonprintable Characters

  2. RFC 20 - ASCII format for network interchange

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rieje
Comment options

@LangLangBart
Comment options

Answer selected by rieje
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants