Added support for arrow keys and page up/down
[iomenu.git] / io-grep
blob7fe4d0fd70a07511809e366bb08ed1140f52a5bf
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 # requires: iomenu
8 CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/iomenu"
10 mkdir -p "$CONFIG"
12 reference="$(
13         while IFS='' read -r directory
14         do
15                 find "$HOME/$directory" ! -path '*/.git/*' -type f |
16                         xargs grep -n "$*" |
17                         cut -c $((${#HOME} + 2))-
18         done < "$CONFIG/grep" |
19                 iomenu
22 path="${reference%%:*}"
23 line="${reference#*:}"
24 line="${line%%:*}"
26 exec ${VISUAL:-${EDITOR:-vim}} +"$line" "$HOME/$path"