~kris/dots

srice

ref: 4471d164e01750db50f2d73d2a7c8af0e2318591 srice/.local/bin/kwic -rwxr-xr-x 314 bytes
4471d164 — Kris Yotam wallpapermenu: pass -no-config so ambient rofi theme can't override the picker 3 months ago
                                                                                
1
2
3
4
5
6
7
8
#!/usr/bin/env bash
# kwic -- KWIC concordancer
# Usage: kwic <pattern> <file> [context_words]
pattern="${1:?Usage: kwic <pattern> <file> [context_words]}"
file="${2:?Provide a file}"
ctx="${3:-5}"
grep -oP "(\S+\s+){0,$ctx}\S*${pattern}\S*(\s+\S+){0,$ctx}" "$file" | \
    sed "s/${pattern}/\x1b[1;31m&\x1b[0m/g"