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-06-08 06:14:08 +02:00
|
|
|
|
RG_PREFIX="rg --hidden --column --line-number --no-heading --follow --color=always --smart-case \
|
|
|
|
|
--glob '!/.ssh' --glob '!/.android' --glob '!/.gnupg' --glob '!node_modules'"
|
2024-06-13 12:04:48 +02:00
|
|
|
|
|
2024-05-18 10:41:08 +02:00
|
|
|
|
INITIAL_QUERY="${*:-}"
|
2024-04-23 04:34:15 +02:00
|
|
|
|
|
2024-06-13 12:04:48 +02:00
|
|
|
|
h_padding=$(printf '%*s' 7 ' ')
|
|
|
|
|
h_gap=$(printf '%*s' 2 ' ')
|
|
|
|
|
HEADER="${h_padding}\
|
|
|
|
|
[1;34m Prefix[1;90m:[0mAlt${h_gap}\
|
|
|
|
|
[1;34m Space[1;90m:[0mfzf/ripgrep${h_gap}\
|
|
|
|
|
[1;34m A[1;90m:[0mSelect All${h_gap}\
|
|
|
|
|
[1;34m D[1;90m:[0mDeselect All${h_gap}\
|
|
|
|
|
[1;34m /[1;90m:[0mToggle Preview${h_gap}\
|
|
|
|
|
[1;34m Q[1;90m:[0mQuickfix List"
|
|
|
|
|
|
|
|
|
|
: | fzf --ansi --multi --disabled --query "$INITIAL_QUERY" \
|
2024-05-18 10:41:08 +02:00
|
|
|
|
--bind "start:reload:$RG_PREFIX {q} $SEARCH_DIR" \
|
|
|
|
|
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} $SEARCH_DIR || true" \
|
2024-06-13 12:04:48 +02:00
|
|
|
|
--bind "alt-space:transform:[[ ! \$FZF_PROMPT =~ ripgrep ]] &&
|
2024-05-18 10:41:08 +02:00
|
|
|
|
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-06-13 12:04:48 +02:00
|
|
|
|
--bind 'alt-a:select-all,alt-d:deselect-all,alt-/:toggle-preview' \
|
2024-07-05 08:58:36 +02:00
|
|
|
|
--margin=5%,10%,5%,10% --height=100% --reverse --info=inline-right \
|
2024-06-08 06:14:08 +02:00
|
|
|
|
--scrollbar=▐ --keep-right --border=none --ellipsis= \
|
2024-05-18 10:41:08 +02:00
|
|
|
|
--prompt 'ripgrep ' \
|
|
|
|
|
--delimiter : \
|
2024-06-13 12:04:48 +02:00
|
|
|
|
--header "$HEADER" --header-first \
|
2024-05-18 10:41:08 +02:00
|
|
|
|
--preview 'bat --style=header,numbers --color=always {1} --highlight-line {2}' \
|
|
|
|
|
--preview-window 'bottom,60%,border-top,+{2}+3/3,~1' \
|
2024-06-13 12:04:48 +02:00
|
|
|
|
--bind "alt-q:execute:nvim +cw -q {+f}" \
|
2024-07-05 08:58:36 +02:00
|
|
|
|
--bind "enter:execute:nvim {1} +{2}" \
|
|
|
|
|
--highlight-line \
|
|
|
|
|
--color=bg+:#2d3f76 \
|
|
|
|
|
--color=bg:#1e2030 \
|
|
|
|
|
--color=border:#589ed7 \
|
|
|
|
|
--color=fg:#c8d3f5 \
|
|
|
|
|
--color=gutter:#1e2030 \
|
|
|
|
|
--color=header:#ff966c \
|
|
|
|
|
--color=hl+:#65bcff \
|
|
|
|
|
--color=hl:#65bcff \
|
|
|
|
|
--color=info:#545c7e \
|
|
|
|
|
--color=marker:#ff007c \
|
|
|
|
|
--color=pointer:#ff007c \
|
|
|
|
|
--color=prompt:#65bcff \
|
|
|
|
|
--color=query:#c8d3f5:regular \
|
|
|
|
|
--color=scrollbar:#589ed7 \
|
|
|
|
|
--color=separator:#ff966c \
|
|
|
|
|
--color=spinner:#ff007c
|
2024-05-18 10:41:08 +02:00
|
|
|
|
|
2024-05-25 17:48:42 +02:00
|
|
|
|
dwmc setlayoutex 0
|