Closed BanchouBoo closed 3 years ago
Interesting idea
--with-nth
was meant for simple use cases (I believe)--with-pattern
option, that would work same as --with-nth
, but would be able to process fzf's placeholdersfzf --with-pattern "{1}{3}{2}"
would be equal to fzf --with-nth 1,3,2
{/terminal_\w+/}.go
would yield "terminal_test.go", "terminal_windows.go" etc.fzf was designed with Unix philosophy in mind, it doesn't try to do things that other programs can do better.
In this case, you can 1. preprocess the input string using any program of your choice, 2. feed the original input along with its modified representation to fzf, 3. hide the original using --with-nth
, 4. and extract the original input string with another filter program. This approach is much more flexible than fzf implementing a certain string transformation mechanism.
find */* | awk '{print $0 "\t" gensub("/", "🌈 ", "g")}' | fzf --delimiter "\t" --with-nth 2.. | awk -F"\t" '{print $1}'
man fzf
)Info
Similar to
with-nth
, but instead of delimiting the input and selecting a field, you just pass in a regex pattern to cut out of the input lines without effecting the final selected output.As an example, I use fzf to select video files to open with mpv, and I have files with names like
[SubsPlease] Fumetsu no Anata e - 01 (1080p) [1D65E30D].mkv
, all the extra information isn't exactly condusive to searching and it's not nice to look at either, and while this one example could be handled with a delimiter, not every file would have the same exact field forwith-nth
so it isn't an effective option. Instead, if I could do something likefzf --cut '(\[\w+\])|(\(\w+\))|\.\w+$'
to transform the line toFumetsu no Anata e - 01
that would be much nicer and more widely applicable.