#!/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} {}" \ --preview-window down )" 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