commit 2ce0a10b0a5af56e10f91024295ab57b2fa282d4 parent 1f5e5723a838dd49a48d1eb5c225ce718b5f86bf Author: William Casarin <jb55@jb55.com> Date: Thu, 12 Nov 2020 17:25:53 -0800 bin/search-files: needed for fuzzy file searches Diffstat:
A | bin/search-files | | | 10 | ++++++++++ |
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/bin/search-files b/bin/search-files @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e +export INITIAL_QUERY="${INITIAL_QUERY:-$@}" +export RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case " +export FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" +res=$(fzf --bind "change:reload:$RG_PREFIX {q} || true" --exit-0 --ansi --phony --query "$INITIAL_QUERY") +file=$(readlink -f $(cut -d: -f1 <<<"$res")) +line=$(cut -d: -f2 <<<"$res") + +echo \"$file\" +$line