diff options
| -rwxr-xr-x | gist | 16 |
1 files changed, 15 insertions, 1 deletions
| @@ -276,7 +276,21 @@ _show_list() { | |||
| 276 | 276 | ||
| 277 | # TODO support filenames, file contents | 277 | # TODO support filenames, file contents |
| 278 | _grep_content() { | 278 | _grep_content() { |
| 279 | hint=false mark=. _show_list | grep -Ei "^ *[^ ]+ [^ ]+ .*$1.*" | 279 | if [[ -z $1 ]]; then echo 'Please give a pattern' && return 1; fi |
| 280 | while read -r index url _ _ _ _ _ _ description; do | ||
| 281 | if grep --color=always -iq "$1" <<<"$description"; then | ||
| 282 | hint=false mark="$index " _show_list | grep --color=always -Ei "$1" | ||
| 283 | else | ||
| 284 | repo=$folder/$(echo $url | sed -E -e 's#.*/##') | ||
| 285 | [[ -d $repo ]] && cd $repo || continue | ||
| 286 | file=$(ls $repo | grep --color=always -Ei "$1") | ||
| 287 | content=$(grep --color=always -EHi "$1" * | head -1) | ||
| 288 | |||
| 289 | [[ -n $file && file="$file\n" || -n $content ]] \ | ||
| 290 | && hint=false mark="$index " _show_list \ | ||
| 291 | && echo -e "$file$content\n" | sed -e 's/^/ /' | ||
| 292 | fi | ||
| 293 | done < $INDEX | ||
| 280 | } | 294 | } |
| 281 | 295 | ||
| 282 | # Open Github repository import page | 296 | # Open Github repository import page |