aboutsummaryrefslogtreecommitdiff
path: root/functions/fzf.sh
diff options
context:
space:
mode:
authorAlec Goncharow <alec@goncharow.dev>2023-12-14 18:37:15 -0500
committerAlec Goncharow <alec@goncharow.dev>2023-12-14 18:37:15 -0500
commitc3575e1f0448faf27d9d00042ed124028b82f26b (patch)
treee6f176b03a83536bf1bbd9f0ca378058c5c6f25a /functions/fzf.sh
parent16234cf74ac878d07cde2a88baf79d1c17f18fec (diff)
sync
Diffstat (limited to 'functions/fzf.sh')
-rwxr-xr-xfunctions/fzf.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/functions/fzf.sh b/functions/fzf.sh
new file mode 100755
index 0000000..8761247
--- /dev/null
+++ b/functions/fzf.sh
@@ -0,0 +1,17 @@
+#!/bin/zsh
+
+function frg {
+ result=$(rg --ignore-case --color=always --line-number --no-heading "$@" |
+ fzf --ansi \
+ --color 'hl:-1:underline,hl+:-1:underline:reverse' \
+ --delimiter ':' \
+ --preview "bat --color=always {1} --theme='gruvbox-dark' --highlight-line {2}" \
+ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3')
+ file=${result%%:*}
+ linenumber=$(echo "${result}" | cut -d: -f2)
+ if [[ -n "$file" ]]; then
+ nvim +"${linenumber}" "$file"
+ fi
+}
+
+alias rgf=frg