2024-05-18 10:41:08 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-04-23 04:34:15 +02:00
|
|
|
|
2024-05-25 17:48:42 +02:00
|
|
|
dwmc setlayoutex 2
|
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
rm -f /tmp/rg-fzf-{r,f}
|
2024-04-23 04:34:15 +02:00
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
[ -d "$1" ] && SEARCH_DIR="$1" && shift || SEARCH_DIR="."
|
2024-04-23 04:34:15 +02:00
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case \
|
|
|
|
--glob '!/.ssh' --glob '!/.android' --glob '!/.gnupg'"
|
|
|
|
INITIAL_QUERY="${*:-}"
|
2024-04-23 04:34:15 +02:00
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
|
|
|
|
--bind "start:reload:$RG_PREFIX {q} $SEARCH_DIR" \
|
|
|
|
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} $SEARCH_DIR || true" \
|
|
|
|
--bind "ctrl-t:transform:[[ ! \$FZF_PROMPT =~ ripgrep ]] &&
|
|
|
|
echo \"rebind(change)+change-prompt(ripgrep )+disable-search+transform-query:echo {q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r\" ||
|
|
|
|
echo \"unbind(change)+change-prompt(fzf )+enable-search+transform-query:echo {q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f\"" \
|
2024-05-25 17:48:42 +02:00
|
|
|
--margin=5%,10%,5%,10% --height=100% --reverse --color=16 --info=inline-right \
|
2024-05-18 10:41:08 +02:00
|
|
|
--scrollbar=▐ --keep-right --info=hidden --border=none --ellipsis= \
|
|
|
|
--prompt 'ripgrep ' \
|
|
|
|
--delimiter : \
|
|
|
|
--header 'CTRL-T: Switch between ripgrep/fzf' \
|
|
|
|
--preview 'bat --style=header,numbers --color=always {1} --highlight-line {2}' \
|
|
|
|
--preview-window 'bottom,60%,border-top,+{2}+3/3,~1' \
|
|
|
|
--bind 'enter:become(nvim {1} +{2})'
|
|
|
|
|
2024-05-25 17:48:42 +02:00
|
|
|
dwmc setlayoutex 0
|
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
# --color "hl:-1:underline,hl+:-1:underline:reverse" \
|