Skip to content

Commit

Permalink
change ripgrep to native fzf (#279)
Browse files Browse the repository at this point in the history
* Fix `Invoke-PsFzfRipgrep` throws `unknown action: change-prompt` after updating to 2.6.1 #273

- Add 'Disabled' param
- Restore unicode icons for git functions and only show in Terminal or non-Windows
- Minor formatting fix

* Fix debug output

* Use fzf directly instead of PowerShell function

* Properly detect if git is installed using scoop regardless of scope (#278)

This fixes the issue #272

---------

Co-authored-by: Kris Borowinski <kris.borowinski@gmail.com>
  • Loading branch information
kelleyma49 and kborowinski authored Sep 30, 2024
1 parent 1acf7da commit 5ef833d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions PSFzf.Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,25 @@ function Invoke-PsFzfRipgrep() {
$env:FZF_DEFAULT_COMMAND = '{0} $(printf %q "{1}")' -f $RG_PREFIX, $INITIAL_QUERY
}
$fzfArguments = @{
Ansi = $true
Disabled = $true
Color = "hl:-1:underline,hl+:-1:underline:reverse"
Query = $INITIAL_QUERY
Prompt = 'ripgrep> '
Delimiter = ':'
Header = '? CTRL-R (Ripgrep mode) ? CTRL -F (fzf mode) ?'
Preview = 'bat --color=always {1} --highlight-line {2}'
PreviewWindow = 'up,60%,border-bottom,+{2}+3/3,~3'
color = "hl:-1:underline,hl+:-1:underline:reverse"
query = $INITIAL_QUERY
prompt = 'ripgrep> '
delimiter = ':'
header = '? CTRL-R (Ripgrep mode) ? CTRL -F (fzf mode) ?'
preview = 'bat --color=always {1} --highlight-line {2}'
'preview-window' = 'up,60%,border-bottom,+{2}+3/3,~3'
}

$fzfArgs = ($fzfArguments.GetEnumerator() | foreach-object { "--{0}=""{1}""" -f $_.Key, $_.Value }) -join ' '

$Bind = @(
'ctrl-r:unbind(change,ctrl-r)+change-prompt(ripgrep> )' + "+disable-search+reload($RG_PREFIX {q} || $trueCmd)+rebind(change,ctrl-f)"
'ctrl-r:unbind(change,ctrl-r)+change-prompt(ripgrep> )' + "+disable-search+reload($RG_PREFIX {q} || $trueCmd)+rebind(change,ctrl-f)"
)
$Bind += 'ctrl-f:unbind(change,ctrl-f)+change-prompt(fzf> )+enable-search+clear-query+rebind(ctrl-r)'
$Bind += "change:reload:$sleepCmd $RG_PREFIX {q} || $trueCmd"
$fzfArgs += ' --ansi --disabled ' + ($Bind | foreach-object { "--bind=""{0}""" -f $_ }) -join ' '

Invoke-Fzf @fzfArguments -Bind $Bind | ForEach-Object { $results += $_ }
Invoke-Expression -Command $('{0} {1}' -f $script:FzfLocation, $fzfArgs) | ForEach-Object { $results += $_ }

# we need this here to prevent the editor launch from inherting FZF_DEFAULT_COMMAND from being overwritten (see #267):
if ($script:OverrideFzfDefaultCommand) {
Expand Down

0 comments on commit 5ef833d

Please sign in to comment.