-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrgf
More file actions
executable file
·39 lines (32 loc) · 1014 Bytes
/
Copy pathrgf
File metadata and controls
executable file
·39 lines (32 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
rg_args=()
for arg in "$@"; do
case "$arg" in
-*)
rg_args+=("$arg") # Collect rg options (-g, --hidden, etc.)
;;
*)
echo "Error: Invalid argument '$arg'. Only rg options are allowed."
exit 1
;;
esac
done
while true; do
selected=$(rg --color=always --line-number --no-heading --smart-case ${rg_args[@]} "$search_term" |
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')
if [[ -z "$selected" ]]; then
echo "No file selected. Exiting."
exit 0
fi
file=$(echo "$selected" | cut -d ':' -f 1)
line=$(echo "$selected" | cut -d ':' -f 2)
nvim "$file" +"$line"
read -p "Continue searching? (y/n): " choice
if [[ "$choice" != "y" ]]; then
exit 0
fi
done