Skip to content

Instantly share code, notes, and snippets.

@CypherpunkSamurai
Created October 16, 2025 11:15
Show Gist options
  • Save CypherpunkSamurai/2272bb8fade9234837f1612c2b0092c3 to your computer and use it in GitHub Desktop.
Save CypherpunkSamurai/2272bb8fade9234837f1612c2b0092c3 to your computer and use it in GitHub Desktop.
B:\Code> function Find-ContentFuzzy {
>> param (
>> [string]$SearchPattern
>> )
>>
>> $selected = rg --color=always --line-number --no-heading $SearchPattern |
>> fzf --ansi `
>> --delimiter ':' `
>> --preview 'bat --color=always --highlight-line {2} --line-range {2}: {1}' `
>> --preview-window 'right:50%:+{2}/2'
>>
>> if ($selected) {
>> $parts = $selected -split ':' | Select-Object -First 2
>> $file = $parts[0]
>> $lineNum = $parts[1]
>> nvim "+$lineNum" $file
>> }
>> }
function Find-ContentFuzzy {
param (
[string]$SearchPattern = ''
)
if ([string]::IsNullOrWhiteSpace($SearchPattern)) {
# No pattern: use rg to list files
$selected = rg --files --color=always |
fzf --ansi `
--preview 'bat --color=always {}' `
--preview-window 'right:50%'
if ($selected) {
nvim $selected
}
}
else {
# With pattern: use ripgrep to search content
$selected = rg --color=always --line-number --no-heading $SearchPattern |
fzf --ansi `
--delimiter ':' `
--preview 'bat --color=always --highlight-line {2} {1}' `
--preview-window 'right:50%:+{2}/2'
if ($selected) {
# More robust parsing that handles Windows paths
if ($selected -match '^(.+?):(\d+):') {
$file = $matches[1]
$lineNum = $matches[2]
nvim "+$lineNum" $file
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment