-
-
Save tecfu/97fe828fde03fa558307450e8a9431ef to your computer and use it in GitHub Desktop.
An interactive fuzzy grep showing surrounding context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
# go get github.com/junegunn/fzf | |
BEFORE=10 | |
AFTER=10 | |
HEIGHT=$(expr $BEFORE + $AFTER + 3 ) # 2 lines for the preview box and 1 extra line fore the match | |
PREVIEW="$@ 2>&1 | grep --color=always -B${BEFORE} -A${AFTER} -F -- {}" | |
"$@" 2>&1 | fzf --height=$HEIGHT --reverse --preview="${PREVIEW}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment