From bc056b042e6508b91705f6d164dc29b18fa0e347 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Tue, 24 Mar 2026 16:03:18 +0900 Subject: modified bin/rgafiles, modified statusbar/sb-mpdup, modified statusbar/sb-playerctlup --- ar/.local/bin/rgafiles | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'ar/.local/bin/rgafiles') diff --git a/ar/.local/bin/rgafiles b/ar/.local/bin/rgafiles index 150ca1d..57b19d4 100755 --- a/ar/.local/bin/rgafiles +++ b/ar/.local/bin/rgafiles @@ -75,17 +75,27 @@ search_term() { openfiles "$files" fi else - # Multiple files: build quickfix entries for line-accurate navigation + # Multiple files: open at matching lines via quickfix tmpfile=$(mktemp) echo "$files" | while IFS= read -r file; do match=$(rga --max-count=1 --line-number --no-filename ${case_flag:+$case_flag} --no-messages "$query" "$file" 2>/dev/null | head -1) if [ -n "$match" ]; then - printf '%s:%s\n' "$file" "$match" >> "$tmpfile" + printf '%s:%s\n' "$(realpath "$file")" "$match" >> "$tmpfile" else - printf '%s:1:\n' "$file" >> "$tmpfile" + printf '%s:1:\n' "$(realpath "$file")" >> "$tmpfile" fi done - ${EDITOR:-nvim} -q "$tmpfile" + if [ "$count" -lt 5 ]; then + ${EDITOR:-nvim} -q "$tmpfile" \ + -c 'for i in range(2,len(getqflist())) | vsplit | execute "cc ".i | endfor | wincmd t' + else + first_line=$(head -1 "$tmpfile" | cut -d: -f2) + file_args="" + while IFS=: read -r fpath _; do + file_args="$file_args \"$fpath\"" + done < "$tmpfile" + eval "${EDITOR:-nvim}" "+${first_line}" "$file_args" + fi rm -f "$tmpfile" fi @@ -146,17 +156,23 @@ list_or_open_project_files() { openfiles "$rga_output" fi else - # Multiple files: build quickfix entries for line-accurate navigation + # Multiple files: open at matching lines via quickfix tmpfile=$(mktemp) for file in $rga_output; do match=$(rga --max-count=1 --line-number --no-filename --no-messages "$project_tag" "$file" 2>/dev/null | head -1) if [ -n "$match" ]; then - printf '%s:%s\n' "$file" "$match" >> "$tmpfile" + printf '%s:%s\n' "$(realpath "$file")" "$match" >> "$tmpfile" else - printf '%s:1:\n' "$file" >> "$tmpfile" + printf '%s:1:\n' "$(realpath "$file")" >> "$tmpfile" fi done - ${EDITOR:-nvim} -q "$tmpfile" + if [ "$file_count" -lt 5 ]; then + ${EDITOR:-nvim} -q "$tmpfile" \ + -c 'for i in range(2,len(getqflist())) | vsplit | execute "cc ".i | endfor | wincmd t' + else + ${EDITOR:-nvim} -q "$tmpfile" \ + -c 'silent! for i in range(2,len(getqflist())+1) | execute "silent! cc ".i | endfor | silent! cfirst' + fi rm -f "$tmpfile" fi fi -- cgit v1.2.3