blob: 6948be88cecdd3c4bfe26a323c4db075458ed1bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env bash
set -euo pipefail
RG_DEFAULT_COMMAND="rg --ignore-case --files-with-matches $*"
readarray -t selected <<< "$(fzf-tmux \
-p "70%" \
--multi \
--exact \
--ansi \
--phony \
--bind "ctrl-a:select-all" \
--bind "change:reload:$RG_DEFAULT_COMMAND {q} || true" \
--print-query \
--preview "rg --ignore-case --pretty --context 2 {q} {}"
)"
query=${selected[0]}
files=("${selected[@]:1}")
if [[ -n "${files:-}" ]]
then
# i don't think this works with emacs...
${EDITOR:-vim} "+/$query" "${files[@]}"
for f in "${files[@]}"
do
echo "$f"
done
fi
|