From 2226c8bf1bc38d5fb612c3e30100fac522f860ee Mon Sep 17 00:00:00 2001 From: gbstan Date: Thu, 12 Dec 2019 21:23:28 +0000 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Examples.md b/Examples.md index a494eb6..2298da6 100644 --- a/Examples.md +++ b/Examples.md @@ -295,13 +295,16 @@ fif() { } ``` +Suggested by [@gbstan](https://github.com/gbstan) + ```sh # alternative using ripgrep-all (rga) combined with preview # allows to search in PDFs, E-Books, Office documents, zip, tar.gz, etc. (see https://github.com/phiresky/ripgrep-all) # find-in-file - usage: fif fif() { - if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi - rga --ignore-case --files-with-matches --no-messages "$1" | fzf-tmux --preview "highlight -O ansi -l {} 2> /dev/null | rga --ignore-case --pretty --context 10 "$1" {}" + if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi + local file + file="$(rga --ignore-case --files-with-matches --no-messages "$@" | fzf-tmux +m --preview="rga --ignore-case --pretty --context 10 '"$@"' {}")" && open "$file" } ```