Skip to content

Instantly share code, notes, and snippets.

@millancore
Created March 25, 2026 09:39
Show Gist options
  • Select an option

  • Save millancore/20d26e7befdc58c7386e2060c9a07383 to your computer and use it in GitHub Desktop.

Select an option

Save millancore/20d26e7befdc58c7386e2060c9a07383 to your computer and use it in GitHub Desktop.
Search, Jump & Edit with Nvim
#!/bin/bash
vrg() {
local result file line
result=$(
rg --line-number \
--glob '!vendor' \
--glob '!node_modules' \
"$1" |
fzf --preview '
f=$(echo {} | cut -d: -f1)
l=$(echo {} | cut -d: -f2)
bat --color=always --highlight-line "$l" "$f"
'
)
if [ -n "$result" ]; then
file=$(echo "$result" | cut -d: -f1)
line=$(echo "$result" | cut -d: -f2)
nvim "+${line}" "${file}"
fi
}
vrg "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment