aboutsummaryrefslogtreecommitdiff
path: root/functions/fzf.sh
blob: 87612471e9bfc6d8e124f9f2a0aa7279ddf3f810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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