{"id":13471913,"url":"https://github.com/tomnomnom/gf","last_synced_at":"2025-05-14T09:06:39.613Z","repository":{"id":41234325,"uuid":"148989843","full_name":"tomnomnom/gf","owner":"tomnomnom","description":"A wrapper around grep, to help you grep for things","archived":false,"fork":false,"pushed_at":"2024-06-08T11:35:23.000Z","size":30,"stargazers_count":1941,"open_issues_count":54,"forks_count":331,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-14T09:05:27.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomnomnom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-16T11:40:55.000Z","updated_at":"2025-05-14T07:18:58.000Z","dependencies_parsed_at":"2023-02-19T02:00:57.957Z","dependency_job_id":"d614f90c-2e79-412f-9f64-4419adace44b","html_url":"https://github.com/tomnomnom/gf","commit_stats":{"total_commits":31,"total_committers":6,"mean_commits":5.166666666666667,"dds":0.3548387096774194,"last_synced_commit":"dcd4c361f9f5ba302294ed38b8ce278e8ba69006"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomnomnom%2Fgf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomnomnom%2Fgf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomnomnom%2Fgf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomnomnom%2Fgf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomnomnom","download_url":"https://codeload.github.com/tomnomnom/gf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:50.328Z","updated_at":"2025-05-14T09:06:39.592Z","avatar_url":"https://github.com/tomnomnom.png","language":"Go","readme":"# gf\n\nA wrapper around grep to avoid typing common patterns.\n\n## What? Why?\n\nI use grep a *lot*. When auditing code bases, looking at the output of [meg](https://github.com/tomnomnom/meg),\nor just generally dealing with large amounts of data. I often end up using fairly complex patterns like this one:\n\n```\n▶ grep -HnrE '(\\$_(POST|GET|COOKIE|REQUEST|SERVER|FILES)|php://(input|stdin))' *\n```\n\nIt's really easy to mess up when typing all of that, and it can be hard to know if you haven't got any\nresults because there are non to find, or because you screwed up writing the pattern or chose the wrong flags.\n\nI wrote `gf` to give names to the pattern and flag combinations I use all the time. So the above command\nbecomes simply:\n\n```\n▶ gf php-sources\n```\n\n### Pattern Files\n\nThe pattern definitions are stored in `~/.gf` as little JSON files that can be kept under version control:\n\n```\n▶ cat ~/.gf/php-sources.json\n{\n    \"flags\": \"-HnrE\",\n    \"pattern\": \"(\\\\$_(POST|GET|COOKIE|REQUEST|SERVER|FILES)|php://(input|stdin))\"\n}\n```\n\nTo help reduce pattern length and complexity a little, you can specify a list of multiple patterns too:\n\n```\n▶ cat ~/.gf/php-sources-multiple.json\n{\n    \"flags\": \"-HnrE\",\n    \"patterns\": [\n        \"\\\\$_(POST|GET|COOKIE|REQUEST|SERVER|FILES)\",\n        \"php://(input|stdin)\"\n    ]\n}\n```\n\nThere are some more example pattern files in the `examples` directory.\n\nYou can use the `-save` flag to create pattern files from the command line:\n\n```\n▶ gf -save php-serialized -HnrE '(a:[0-9]+:{|O:[0-9]+:\"|s:[0-9]+:\")'\n```\n\n### Auto Complete\n\nThere's an auto-complete script included, so you can hit 'tab' to show you what your options are:\n\n```\n▶ gf \u003ctab\u003e\nbase64       debug-pages  fw           php-curl     php-errors   php-sinks    php-sources  sec          takeovers    urls\n```\n\n#### Bash\n\nTo get auto-complete working you need to `source` the `gf-completion.bash` file in your `.bashrc` or similar:\n\n```\nsource ~/path/to/gf-completion.bash\n```\n\n#### Zsh\n\nTo get auto-complete working you need to enable autocomplete (not needed if you have oh-my-zsh) using `autoload -U compaudit \u0026\u0026 compinit` or by putting it into `.zshrc`\n\nThen `source` the `gf-completion.zsh` file in your `.zshrc` or similar:\n\n```\nsource ~/path/to/gf-completion.zsh\n```\n\nNote: if you're using oh-my-zsh or similar you may find that `gf` is an alias for `git fetch`. You can either\nalias the gf binary to something else, or `unalias gf` to remove the `git fetch` alias.\n\n### Using custom engines\n\nThere are some amazing code searching engines out there that can be a better replacement for grep.\nA good example is [the silver searcher](https://github.com/ggreer/the_silver_searcher).\nIt's faster (like **way faster**) and presents the results in a more visually digestible manner.\nIn order to utilize a different engine, add `engine: \u003cother tool\u003e` to the relevant pattern file:\n```bash\n# Using the silver searcher instead of grep for the aws-keys pattern:\n# 1. Adding \"ag\" engine\n# 2. Removing the E flag which is irrelevant for ag\n{\n  \"engine\": \"ag\",\n  \"flags\": \"-Hanr\",\n  \"pattern\": \"([^A-Z0-9]|^)(AKIA|A3T|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{12,}\"\n}\n```\n* Note: Different engines use different flags, so in the example above, the flag `E` has to be removed from the `aws-keys.json` file in order for ag to successfully run.\n\n\n## Install\n\nIf you've got Go installed and configured you can install `gf` with:\n\n```\n▶ go get -u github.com/tomnomnom/gf\n```\n\nIf you've installed using `go get`, you can enable auto-completion to your `.bashrc` like this:\n\n```\n▶ echo 'source $GOPATH/src/github.com/tomnomnom/gf/gf-completion.bash' \u003e\u003e ~/.bashrc\n```\n\nNote that you'll have to restart your terminal, or run `source ~/.bashrc` for the changes to\ntake effect.\n\nTo get started quickly, you can copy the example pattern files to `~/.gf` like this:\n\n```\n▶ cp -r $GOPATH/src/github.com/tomnomnom/gf/examples ~/.gf\n```\n\nMy personal patterns that I've included as examples might not be very useful to you, but hopefully\nthey're still a reasonable point of reference.\n\n## Contributing\n\nI'd actually be most interested in new pattern files! If you've got something you regularly grep for\nthen feel free to issue a PR to add new pattern files to the examples directory.\n\nBug fixes are also welcome as always :)\n","funding_links":[],"categories":["Go","Miscellaneous","Weapons","Other"],"sub_categories":["Useful","Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomnomnom%2Fgf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomnomnom%2Fgf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomnomnom%2Fgf/lists"}