diff --git a/profile/_assets/bin/rgv b/profile/_assets/bin/rgv new file mode 100755 index 0000000000000000000000000000000000000000..216759a90c945aa7b0a1c339b9fe11f80da88674 --- /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 0000000000000000000000000000000000000000..6600cc22defc4d2729bf8d5ef50636a0a1311dc1 --- /dev/null +++ b/profile/rda/bin/rgv @@ -0,0 +1 @@ +../../_assets/bin/rgv \ No newline at end of file