From deba5e4902675bc6772d70650850c4df5635f2e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch>
Date: Fri, 6 Sep 2024 11:03:57 +0200
Subject: [PATCH] Add rgv in profile rda

---
 profile/_assets/bin/rgv | 19 +++++++++++++++++++
 profile/rda/bin/rgv     |  1 +
 2 files changed, 20 insertions(+)
 create mode 100755 profile/_assets/bin/rgv
 create mode 120000 profile/rda/bin/rgv

diff --git a/profile/_assets/bin/rgv b/profile/_assets/bin/rgv
new file mode 100755
index 0000000..216759a
--- /dev/null
+++ b/profile/_assets/bin/rgv
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# 1. Search for text in files using Ripgrep
+# 2. Interactively restart Ripgrep with reload action
+# 3. Open the file in Vim
+# Source: https://github.com/junegunn/fzf/blob/master/ADVANCED.md
+#
+RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
+INITIAL_QUERY="${*:-}"
+IFS=: read -ra selected < <(
+  FZF_DEFAULT_COMMAND="$RG_PREFIX $(printf %q "$INITIAL_QUERY")" \
+  fzf --ansi \
+      --disabled --query "$INITIAL_QUERY" \
+      --bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
+      --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]}" ] && vim "${selected[0]}" "+${selected[1]}"
diff --git a/profile/rda/bin/rgv b/profile/rda/bin/rgv
new file mode 120000
index 0000000..6600cc2
--- /dev/null
+++ b/profile/rda/bin/rgv
@@ -0,0 +1 @@
+../../_assets/bin/rgv
\ No newline at end of file
-- 
GitLab