All Projects → k1LoW → gh-grep

k1LoW / gh-grep

Licence: MIT license
Print lines matching a pattern in repositories using GitHub API

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to gh-grep

gh-markdown-preview
GitHub CLI extension to preview Markdown looks like GitHub.
Stars: ✭ 174 (+20.83%)
Mutual labels:  gh-extension
gh-ost
gh extension to meet ghost.
Stars: ✭ 65 (-54.86%)
Mutual labels:  gh-extension
gh-token
Create an installation access token for a GitHub app from your terminal 💻
Stars: ✭ 154 (+6.94%)
Mutual labels:  gh-extension
gh-poi
✨ Safely clean up your local branches
Stars: ✭ 35 (-75.69%)
Mutual labels:  gh-extension
gh-prs
gh cli extension to display a dashboard of PRs - configurable with a beautiful UI.
Stars: ✭ 443 (+207.64%)
Mutual labels:  gh-extension
gh-notify
GitHub CLI extension to display GitHub notifications
Stars: ✭ 66 (-54.17%)
Mutual labels:  gh-extension
gh-repo-explore
GitHub CLI extension to interactively explore a repo without cloning
Stars: ✭ 34 (-76.39%)
Mutual labels:  gh-extension
gh-f
🔎 the ultimate compact fzf gh extension
Stars: ✭ 97 (-32.64%)
Mutual labels:  gh-extension
gh-fuzzyclone
No description or website provided.
Stars: ✭ 24 (-83.33%)
Mutual labels:  gh-extension
resto
🔗 a CLI app can send pretty HTTP & API requests with TUI
Stars: ✭ 113 (-21.53%)
Mutual labels:  gh-extension

gh-grep

:octocat: Print lines matching a pattern in repositories using GitHub API

Usage

$ gh grep func.*schema.Schema --include=**/*.go --owner k1LoW --repo tbls
k1LoW/tbls:cmd/doc.go:func withDot(s *schema.Schema, c *config.Config, force bool) (e error) {
k1LoW/tbls:cmd/doc.go:func outputErExists(s *schema.Schema, path string) bool {
k1LoW/tbls:config/config.go:func (c *Config) ModifySchema(s *schema.Schema) error {
k1LoW/tbls:config/config.go:func (c *Config) MergeAdditionalData(s *schema.Schema) error {
k1LoW/tbls:config/config.go:func (c *Config) FilterTables(s *schema.Schema) error {
k1LoW/tbls:config/config.go:func (c *Config) mergeDictFromSchema(s *schema.Schema) {
k1LoW/tbls:config/config.go:func excludeTableFromSchema(name string, s *schema.Schema) error {
[...]

( Do grep the codes (**/*.go) of k1LoW/tbls with the pattern func.*schema.Schema )

$ gh grep --help
Print lines matching a pattern in repositories using GitHub API

Usage:
  gh-grep [PATTERN] [flags]

Flags:
  -e, -- strings         match pattern
      --branch string    branch name
  -c, --count            show the number of matches instead of matching lines
      --exclude string   skip files and directories matching pattern
  -h, --help             help for gh-grep
  -i, --ignore-case      case insensitive matching
      --include string   search only files that match pattern (default "**/*")
  -n, --line-number      show line numbers
      --name-only        show only repository:filenames
  -o, --only-matching    show only matching parts of a line
      --owner string     repository owner or org
      --repo strings     repository name
      --repo-only        show only repositories
      --tag string       tag name
      --url              show URL
  -v, --version          version for gh-grep

⚠️ Notice ⚠️

gh-grep is very slow because it does all its scanning through the GitHub API.

It is recommended to specify the --include option to get the results in a realistic time.

Examples

List base Docker images used in the Dockerfile of the project root

$ gh grep ^FROM --include=Dockerfile --owner k1LoW
k1LoW/centve:Dockerfile:FROM centos:7
k1LoW/docker-alpine-pandoc-ja:Dockerfile:FROM frolvlad/alpine-glibc
k1LoW/docker-sshd:Dockerfile:FROM docker.io/alpine:3.9
k1LoW/gh-grep:Dockerfile:FROM debian:buster-slim
k1LoW/ghdag:Dockerfile:FROM debian:buster-slim
k1LoW/ghdag-action:Dockerfile:FROM ghcr.io/k1low/ghdag:v0.16.0
k1LoW/ghput:Dockerfile:FROM alpine:3.13
k1LoW/ghput-release-action:Dockerfile:FROM ghcr.io/k1low/ghput:v0.12.0
k1LoW/github-script-ruby:Dockerfile:FROM ghcr.io/k1low/github-script-ruby-base:v1.1.0
[...]

List Actions you are using

$ gh grep uses: --include=.github/workflows/* --owner k1LoW | sed -e 's/.*uses:\s*//g' | sort | uniq -c
   9 ./
   1 EndBug/add-and-commit@v7
   2 actions/checkout@master
  10 actions/checkout@v1
  50 actions/checkout@v2
  18 actions/setup-go@v1
  21 actions/setup-go@v2
   4 aquasecurity/trivy-action@master
[...]

Open the matched lines in a browser.

$ gh grep 'ioutil\.' --include=**/*.go --owner k1LoW --repo ghput --url
https://github.com/k1LoW/ghput/blob/main/gh/gh.go#L300
https://github.com/k1LoW/ghput/blob/main/gh/gh.go#L313
$ gh grep 'ioutil\.' --include=**/*.go --owner k1LoW --repo ghput --url | xargs open

*open command only works on macOS.

Install

gh-grep can be installed as a standalone command or as a GitHub CLI extension

Install as a GitHub CLI extension

$ gh extension install k1LoW/gh-grep

Install as a standalone command

Run gh-grep instead of gh grep.

deb:

$ export GH-GREP_VERSION=X.X.X
$ curl -o gh-grep.deb -L https://github.com/k1LoW/gh-grep/releases/download/v$GH-GREP_VERSION/gh-grep_$GH-GREP_VERSION-1_amd64.deb
$ dpkg -i runn.deb

RPM:

$ export GH-GREP_VERSION=X.X.X
$ yum install https://github.com/k1LoW/gh-grep/releases/download/v$GH-GREP_VERSION/gh-grep_$GH-GREP_VERSION-1_amd64.rpm

apk:

$ export GH-GREP_VERSION=X.X.X
$ curl -o gh-grep.apk -L https://github.com/k1LoW/gh-grep/releases/download/v$GH-GREP_VERSION/gh-grep_$GH-GREP_VERSION-1_amd64.apk
$ apk add gh-grep.apk

homebrew tap:

$ brew install k1LoW/tap/gh-grep

macports:

$ sudo port install gh-grep

Maintainer: @herbygillot

manually:

Download binary from releases page

go get:

$ go get github.com/k1LoW/gh-grep

docker:

$ docker pull ghcr.io/k1low/gh-grep:latest
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].