Skip to content
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

How do you pass arguments to fzf #308

Closed
KiLLeRRaT opened this issue Mar 15, 2024 · 2 comments
Closed

How do you pass arguments to fzf #308

KiLLeRRaT opened this issue Mar 15, 2024 · 2 comments

Comments

@KiLLeRRaT
Copy link

Hi,

I see in the manual you can use --fzf to pass params to fzf.

I can't get this to work.

These are the commands I've been trying to run:

With double quotes

❯ rg smrc --files-with-matches | sad 'smrc' 'smc' --fzf "--bind ctrl-a:select-all"
error: unexpected argument '--bind ctrl-a:select-all' found

  tip: to pass '--bind ctrl-a:select-all' as a value, use '-- --bind ctrl-a:select-all'

Usage: sad <PATTERN|REPLACE|--read0|--commit|--exact|--flags <FLAGS>|--pager <PAGER>|--fzf <FZF>|--unified <UNIFIED>>

For more information, try '--help'.

No dashes before bind

 rg smrc --files-with-matches | sad 'smrc' 'smc' --fzf "bind ctrl-a:select-all"
unknown option: bind
Error:
IO(
    "/usr/bin/fzf",
    BrokenPipe,
)
Error:
BadExit(
    "/usr/bin/fzf",
    2,
)

No double quotes

❯ rg smrc --files-with-matches | sad 'smrc' 'smc' --fzf --bind=ctrl-a:select-all
error: unexpected argument '--bind' found

  tip: to pass '--bind' as a value, use '-- --bind'

Usage: sad <PATTERN|REPLACE|--read0|--commit|--exact|--flags <FLAGS>|--pager <PAGER>|--fzf <FZF>|--unified <UNIFIED>>

For more information, try '--help'.

Any ideas what's going on?

Looks like it should work reading the source code. Something that has me worrying about bind specifically is the function you run around the --bind args in the code though.

sad/src/fzf.rs

Line 142 in a0dc8b3

format!("--bind=enter:{execute}"),

Thanks!

@jiangyinzuo
Copy link

jiangyinzuo commented May 17, 2024

@KiLLeRRaT Adding a backslash \ works well for me.

fd | sad Duck Chicken --fzf '\--bind ctrl-a:select-all'

@KiLLeRRaT
Copy link
Author

That seems to do the trick! Thanks :)

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

No branches or pull requests

2 participants