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

ripgrep support for powershell #1860

Open
GeorgeManukyan opened this issue Nov 25, 2024 · 1 comment
Open

ripgrep support for powershell #1860

GeorgeManukyan opened this issue Nov 25, 2024 · 1 comment

Comments

@GeorgeManukyan
Copy link

Could someone please help me convert this script to work in PowerShell?
cmd fzf_search ${{
# Define the search command with ripgrep

$cmd = "rg --column --line-number --no-heading --color=always --smart-case"
fzf --ansi --disabled --layout=reverse --header="Search in files" --delimiter=: `
		--bind "start:reload:$cmd {q}" `
		--bind "change:reload:sleep 0.1 & $cmd {q} || rem" `
		--bind="enter:become(lf -remote -- **But what goest here?** 
		--preview 'bat --color=always --highlight-line={2} -- {1}' `
		--preview-window "up,60%,border-bottom,+{2}+3/3"
}}
@joelim-work
Copy link
Collaborator

I played around with this briefly and ended up with the following:

cmd fzf_search ${{
    $cmd = "rg --column --line-number --no-heading --color=always --smart-case"

    $result = (fzf --ansi --disabled --layout=reverse --height="100%" --header="Search in files" --delimiter=":" `
        --bind "start:reload($cmd {q})" `
        --bind "change:reload($cmd {q})" `
        --preview 'bat --color=always --highlight-line={2} -- {1}' `
        --preview-window "up,60%,border-bottom,+{2}+3/3" `
    ).Split(':')[0]

    lf -remote "send $env:id select `"$result`""
}}

Hopefully this is enough for you to use as a starting point.

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