diff options
| author | Anton Bobov <anton@bobov.name> | 2023-08-29 14:44:07 +0500 |
|---|---|---|
| committer | Anton Bobov <anton@bobov.name> | 2023-08-29 14:44:07 +0500 |
| commit | 14325e1964c5939e5139297ce5897f929dc1e025 (patch) | |
| tree | a39db488ee3aef27ca1c07e877fecc302bdf5554 /ag-preview | |
| parent | 7fb714fadb768401b251a7584d76f216acf5943a (diff) | |
Add scripts
Diffstat (limited to 'ag-preview')
| -rwxr-xr-x | ag-preview | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ag-preview b/ag-preview new file mode 100755 index 0000000..e210682 --- /dev/null +++ b/ag-preview @@ -0,0 +1,18 @@ +#!/bin/bash +# Based on https://github.com/junegunn/fzf/blob/master/ADVANCED.md#ripgrep-integration + +set -euo pipefail + +main() { + AG_PREFIX="ag --column --numbers --noheading --color --smart-case" + INITIAL_QUERY="${*:-}" + : | fzf --ansi --disabled --query "$INITIAL_QUERY" \ + --bind "start:reload:$AG_PREFIX {q}" \ + --bind "change:reload:sleep 0.1; $AG_PREFIX {q} || true" \ + --delimiter : \ + --preview 'bat --color=always {1} --highlight-line {2}' \ + --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \ + --bind 'enter:become(vim {1} +{2})' +} + +main "$@" |
