From a148531d3fc1a8a740d5b09ea8b00df870db064c Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Sat, 10 Jul 2021 11:13:56 +0530 Subject: [PATCH] fish: Add shortcuts for searching with ripgrep within in a file This is primarily to help us with grepping in gstreamer logs. --- fish/.config/fish/config.fish | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fish/.config/fish/config.fish b/fish/.config/fish/config.fish index 652f9be..8e8c66f 100644 --- a/fish/.config/fish/config.fish +++ b/fish/.config/fish/config.fish @@ -306,6 +306,18 @@ function ffr --description "Git restore a file using fzf" git restore $argv -- (git ls-files --modified --exclude-standard | fzf -m) end +function grf --description "Search within a file with grep with context" + grep --color=always -C 10 --group-separator="---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" $argv | less -R +end + +function rgf --description "Search within a file with ripgrep" + rg --color always $argv | nvim -R +AnsiEsc +end + +function rgc --description "Search within a file with ripgrep with context" + rg --color always -C 10 --context-separator="---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" $argv | nvim -R +AnsiEsc +end + fzf_key_bindings starship init fish | source