# msgid "" msgstr "" msgid "" "title: Grep online repositories\n" "date: 2020-08-28\n" "layout: post\n" "lang: en\n" "ref: grep-online-repositories" msgstr "" msgid "" "I often find interesting source code repositories online that I want to grep" " for some pattern but I can't, because either:" msgstr "" msgid "" "the repository is on [cgit](https://git.zx2c4.com/cgit/) or a similar code " "repository that doesn't allow search in files, or;" msgstr "" msgid "" "the search function is really bad, and doesn't allow me to use regular " "expressions for searching patterns in the code." msgstr "" msgid "" "Here's a simple script that allows you to overcome that problem easily:" msgstr "" msgid "" "It is a wrapper around `git grep` that downloads the repository when " "missing. Save in a file called `git-search`, make the file executable and " "add it to your path." msgstr "" msgid "Overview:" msgstr "" msgid "*lines 1~2*:" msgstr "" msgid "" "Bash shebang and the `set -eu` options to exit on error or undefined " "variables." msgstr "" msgid "*lines 4~30*:" msgstr "" msgid "Usage text to be printed when providing less arguments than expected." msgstr "" msgid "*line 33*:" msgstr "" msgid "Extract the repository name from the URL, removing trailing slashes." msgstr "" msgid "*lines 34~37*:" msgstr "" msgid "Download the repository when missing and go to the folder." msgstr "" msgid "*line 39*:" msgstr "" msgid "Make the variable `$@` contain the rest of the unused arguments." msgstr "" msgid "*line 40*:" msgstr "" msgid "Perform `git grep`, forwarding the remaining arguments from `$@`." msgstr "" msgid "Example output:" msgstr "" msgid "" "Subsequent greps on the same repository are faster because no download is " "needed." msgstr "" msgid "When no argument is provided, it prints the usage text:" msgstr ""