Skip to content

Commit

Permalink
set delta as pager for ripgrep
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Nov 11, 2024
1 parent 7dac324 commit bbc05d2
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -275,22 +275,19 @@ prompt pure
# Basic commands
alias zcat='zcat -f'
alias dd='dd status=progress'
if [[ -n ${commands[rg]} ]]; then
rg() {
command rg -C1 --sort path --pretty --smart-case --fixed-strings "$@" | less -R
}
ag() {
echo "use rg instead"
sleep 1
rg "$@"
}
elif [[ -n ${commands[ag]} ]]; then
alias ag="ag --color --smart-case --literal --pager=$PAGER"
fi
rg() {
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
elif [[ -n ${commands[ag]} ]]; then
command ag -C2 --smart-case --literal --pager="$PAGER" "$@"
else
grep -r -C 2 "$@"
fi
}
if [[ -n ${commands[zoxide]} ]]; then
eval "$(zoxide init zsh)"
else
alias z="builtin cd"
fi
if [[ -n ${commands[nom-build]} ]]; then
alias nix-build=nom-build
Expand Down Expand Up @@ -744,6 +741,7 @@ function delta_sidebyside {
}
trap delta_sidebyside WINCH


mkcd() { mkdir -p "$1" && cd "$1"; }
# make cd accept files
cd() {
Expand Down

0 comments on commit bbc05d2

Please sign in to comment.