-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrgs
More file actions
executable file
·25 lines (21 loc) · 728 Bytes
/
rgs
File metadata and controls
executable file
·25 lines (21 loc) · 728 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
#!/usr/bin/env bash
RCS_CMD="goscope"
INITIAL_QUERY="${*:-}"
selected=$(FZF_DEFAULT_COMMAND=$RCS_CMD \
fzf --ansi \
--bind "change:reload:sleep 0.1; $RCS_CMD || true" \
--delimiter ' ' \
--preview 'file=$(echo {2} | cut -d":" -f1); \
line=$(echo {2} | cut -d":" -f2); \
start=$(( line > 10 ? line - 10 : 1 )); \
end=$(( line + 10 )); \
bat --color=always --highlight-line "$line" --line-range "$start:$end" "$file"' \
--preview-window 'up,60%,border-bottom' \
--query "$INITIAL_QUERY")
if [ -n "$selected" ]; then
IFS=' ' read -r function file_line <<< "$selected"
file="${file_line%%:*}"
line="${file_line#*:}"
$EDITOR "$file" "+$line"
echo "$file +$line"
fi