| 1 | ## search code, preview, open to line |
| 2 | # |
| 3 | function rga |
| 4 | if test (count $argv) -eq 0 |
| 5 | echo 'usage: rga <pattern>'; return 1 |
| 6 | end |
| 7 | set -l out (rg --line-number --no-heading --color=always --smart-case $argv \ |
| 8 | | _fzf --ansi --delimiter : \ |
| 9 | --preview 'bat --style=numbers --color=always --highlight-line {2} {1}') |
| 10 | test -n "$out"; or return |
| 11 | set -l file (echo $out | cut -d: -f1) |
| 12 | set -l line (echo $out | cut -d: -f2) |
| 13 | open_at_line "$file" "$line" |
| 14 | end |