Skip to content

Commit

Permalink
ripgrep: also search for files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Nov 11, 2024
1 parent bbc05d2 commit 4dbb413
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,16 @@ prompt pure
alias zcat='zcat -f'
alias dd='dd status=progress'
rg() {
local pager=$PAGER

if [[ -n ${commands[delta]} ]]; then
command rg --json -C 2 "$@" | delta
elif [[ -n ${commands[rg]} ]]; then
command rg -C1 --sort path --pretty --smart-case --fixed-strings "$@" | $PAGER
pager=delta
fi

if [[ -n ${commands[rg]} ]]; then
( command rg --json -C 2 "$@"; command rg --files | command rg --no-line-number --json -C 2 "$@" ) | $pager
elif [[ -n ${commands[ag]} ]]; then
command ag -C2 --smart-case --literal --pager="$PAGER" "$@"
command ag -C2 --smart-case --literal --pager="$pager" "$@"
else
grep -r -C 2 "$@"
fi
Expand Down

0 comments on commit 4dbb413

Please sign in to comment.