mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-25 10:15:37 +00:00
26 lines
760 B
Plaintext
26 lines
760 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
# Credit: https://github.com/junegunn/fzf/blob/master/ADVANCED.md
|
||
|
# Requires bash.
|
||
|
|
||
|
# 1. Search for text in files using Ripgrep
|
||
|
# 2. Interactively narrow down the list using fzf
|
||
|
# 3. Open the file in Vim
|
||
|
IFS=: read -ra selected < <(
|
||
|
rg \
|
||
|
--color=always \
|
||
|
--line-number \
|
||
|
--no-heading \
|
||
|
--smart-case \
|
||
|
--iglob !/Library/** \
|
||
|
--iglob !/System/** \
|
||
|
--iglob "!Users/$HOME/Library/*" \
|
||
|
"${*:-}" |
|
||
|
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'
|
||
|
)
|
||
|
[ -n "${selected[0]}" ] && nvim "${selected[0]}" "+${selected[1]}"
|