Only 4 errors on Valgrin on a full cycle! \o/
[iomenu.git] / io-grep
blobca4b8b5b1247efbf74f48ce45587668b504aab6d
1 # grep through all files and open one in editor
3 # Directory to be searched can be set in ~/.config/iomenu/grep.  They are
4 # relative to "$HOME"
6 mkdir -p "$CONFIG"
8 reference="$(
9         find "$1" ! -path '*/.git/*' -type f |
10                 xargs -n 1 grep -n |
11                 cut -c $((${#HOME} + 2))- |
12                 iomenu -n
15 path="${reference%%:*}"
16 line="${reference#*:}"
17 line="${line%%:*}"
19 exec ${VISUAL:-${EDITOR:-vim}} +"$line" "$HOME/$path"