diff options
| -rwxr-xr-x | gist | 19 |
1 files changed, 9 insertions, 10 deletions
| @@ -48,7 +48,6 @@ | |||
| 48 | # Since now a gist is a local cloned repo | 48 | # Since now a gist is a local cloned repo |
| 49 | # It is your business to do git commit and git push | 49 | # It is your business to do git commit and git push |
| 50 | 50 | ||
| 51 | # FIXME g g s | g l | ||
| 52 | # TODO IF in pipe, do not apply configure | 51 | # TODO IF in pipe, do not apply configure |
| 53 | # TODO change gist from public to private or reverse versa | 52 | # TODO change gist from public to private or reverse versa |
| 54 | # TODO feature to exclude tag-value or grep-string | 53 | # TODO feature to exclude tag-value or grep-string |
| @@ -356,15 +355,15 @@ _grep_content() { | |||
| 356 | else | 355 | else |
| 357 | local repo=${folder}/${gist_id} | 356 | local repo=${folder}/${gist_id} |
| 358 | [[ -d $repo ]] && cd $repo || continue | 357 | [[ -d $repo ]] && cd $repo || continue |
| 359 | # grep from filenames | 358 | local result=$({ |
| 360 | local file=$(ls $repo | grep --color=always -Ei "$1") | 359 | # grep from filenames |
| 361 | # grep from content of files | 360 | ls $repo | grep --color=always -Ei "$1" |
| 362 | # Abort error message to prevent weird file name, for example: https://gist.github.com/6057f4a3a533f7992c60 | 361 | # grep from content of files |
| 363 | local content=$(grep --color=always -EHi -m1 "$1" * 2>/dev/null | head -1) | 362 | # Abort error message to prevent weird file name, for example: https://gist.github.com/6057f4a3a533f7992c60 |
| 364 | 363 | grep --color=always -EHi -m1 "$1" * 2>/dev/null | head -1 | |
| 365 | [[ -n $file && file="$file\n" || -n $content ]] \ | 364 | }) |
| 366 | && hint=false mark="$index " _print_records \ | 365 | |
| 367 | && echo -e " $file$content" | 366 | [[ -n $result ]] && hint=false mark="$index " _print_records && sed -e 's/^/ /' <<<"$result" |
| 368 | fi | 367 | fi |
| 369 | done | 368 | done |
| 370 | } | 369 | } |