Skip to content

Instantly share code, notes, and snippets.

@redraw
Created December 31, 2024 15:14
Show Gist options
  • Save redraw/e97870a0a575ce18b7dc876c8f1dab36 to your computer and use it in GitHub Desktop.
Save redraw/e97870a0a575ce18b7dc876c8f1dab36 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# 1. Search for text in files using Ripgrep
# 2. Interactively narrow down the list using fzf
# 3. Open the file in Vim
rg --color=always --line-number --no-heading --smart-case -t txt "${*:-}" |
fzf --ansi \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
--bind 'enter:execute(vim {1} +{2} < /dev/tty)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment