• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 gh-grep.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

More Repositories

1

tbls

tbls is a CI-Friendly tool for document a database, written in Go.
Go
2,344
star
2

awspec

RSpec tests for your AWS resources.
Ruby
1,173
star
3

octocov

octocov is a toolkit for collecting code metrics (code coverage, code to test ratio and test execution time).
Go
198
star
4

ndiag

ndiag is a high-level architecture diagramming/documentation tool.
Go
176
star
5

serverless-s3-sync

A plugin to sync local directories and S3 prefixes for Serverless Framework โšก
JavaScript
170
star
6

runn

runn is a package/tool for running operations following a scenario.
Go
154
star
7

tcpdp

tcpdp is TCP dump tool with custom dumper and structured logger written in Go.
Go
125
star
8

filt

filt is a interactive/realtime stream filter ( also known as "trial-and-error pipe" ).
Go
74
star
9

evry

Split STDIN stream and execute specified command every N lines/seconds.
Go
64
star
10

colr

๐ŸŽจ colr colors strings, colorfully.
Go
59
star
11

ghput

:octocat: ghput is a CI-friendly tool that puts * on GitHub.
Go
34
star
12

harvest

๐Ÿชฒ Portable log aggregation tool for middle-scale system operation/troubleshooting.
Go
31
star
13

utsusemi

A tool to generate a static website by crawling the original site.
JavaScript
30
star
14

emacs-cake

Minor Mode for editing CakePHP code in Emacs
Emacs Lisp
27
star
15

sakuravps

Shell
27
star
16

emacs-drill-instructor

Enforce key-bind of Emacs. a.k.a ้ฌผ่ปๆ›น.el
Emacs Lisp
27
star
17

frgm

frgm is a meta snippet (fragment) manager.
Go
25
star
18

holiday_jp

[DEPRECATED PROJECT] holiday_jp
Ruby
23
star
19

github-script-ruby

Write workflows scripting the GitHub API in Ruby
Ruby
23
star
20

ghdag

:octocat: ghdag is a tiny workflow engine for GitHub issue and pull request.
Go
23
star
21

fatty

Simple Git repogitory browser plugin for CakePHP
JavaScript
22
star
22

serverless-static-hosting-with-basic-auth

Serverless boilerplate for Static website hosting with Basic authentication
JavaScript
21
star
23

trivy-db-to

trivy-db-to is a tool for migrating/converting vulnerability information from Trivy DB to other datasource.
Go
19
star
24

yalog

Yet Another Logger for CakePHP
PHP
19
star
25

awsdo

awsdo is a tool to do anything using AWS temporary credentials.
Go
19
star
26

execop

ExeCop is a checker that check commands and environment variables before execute command.
Shell
18
star
27

emacs-titanium

Minor Mode for editing Titanium code in Emacs
Emacs Lisp
17
star
28

koma

Koma is an inventory monitoring tool that doesnโ€™t require agent installation on the sever side.
Ruby
17
star
29

awsecrets

AWS credentials loader
Ruby
17
star
30

sheer-heart-attack

๐Ÿ’ฃ A debugging tool that can execute any command on process/host metrics trigger ๐Ÿ’ฅ .
Go
17
star
31

octocov-action

:octocat: GitHub Action for octocov
Shell
17
star
32

certman

CLI tool for AWS Certificate Manager.
Ruby
17
star
33

aws-graph

Draw AWS network graph with Graphviz.
Ruby
16
star
34

sconb

Ssh CONfig Buckup tool.
Ruby
16
star
35

docker-alpine-pandoc-ja

Pandoc for Japanese based on Alpine Linux
Dockerfile
15
star
36

model_info

CakePHP DB Schema/Model Info Plugin
PHP
13
star
37

fake

Fixture generator plugin for cAKEphp.
PHP
13
star
38

viewpath

Viewpath: View file path display plugin for CakePHP
PHP
12
star
39

CacooViewer

Simple `Cacoo' diagrams viewer.
JavaScript
12
star
40

Yacsv

Yet another CSV utility plugin for CakePHP
PHP
12
star
41

grouped_process_exporter

Exporter for grouped process
Go
11
star
42

emacs-serverspec

Serverspec minor mode
Emacs Lisp
11
star
43

dirmap

๐Ÿ“ dirmap is a tool for generating a directory map.
Go
11
star
44

metr

metr provides an easy way to use host/process metrics for shell script/monitoring tool.
Go
11
star
45

gh-setup

:octocat: Setup asset of Github releases.
Go
10
star
46

connected

๐Ÿ”Œ Watch your MacBook connection โšก
Go
10
star
47

glyph

Icon as Code
Go
10
star
48

controller_prefix

`Controller name prefix' custom route plugin for CakePHP
PHP
10
star
49

emacs-cake2

Minor Mode for editing CakePHP2 code in Emacs
Emacs Lisp
10
star
50

sshc

sshc.NewClient() returns *ssh.Client using ssh_config(5)
Go
10
star
51

tbls-ask

tbls-ask is an external subcommand of tbls for asking OpenAI using the datasource.
Go
10
star
52

tokyotyrant_php

Yet Another "Tokyo Tyrant" PHP Interface
PHP
9
star
53

pr-bullet

pr-bullet is a tool for copying pull request to multiple repositories.
Go
9
star
54

recipe

recipe - CakePHP CLI Package Installer -
PHP
9
star
55

emacs-historyf

file history library like browser
Emacs Lisp
9
star
56

escape

Auto escaping plugin for CakePHP
PHP
8
star
57

yak

Yet Another Ktai plugin for CakePHP
PHP
8
star
58

ebk

ebk is a tiny tool for ebook
Go
8
star
59

emacs-ac-cake2

Emacs Lisp
8
star
60

pear_local

PEAR Local install plugin for CakePHP
PHP
8
star
61

stopw

A stopwatch library in Go for nested time measurement.
Go
8
star
62

emacs-ac-cake

Emacs Lisp
8
star
63

duration

duration.Parse() parses a formatted string and returns the time.Duration value it represents.
Go
8
star
64

auto-complete-exuberant-ctags

Exuberant ctags auto-complete.el source
Emacs Lisp
8
star
65

has_no

Simple binding model practice plugin for CakePHP.
PHP
7
star
66

mackerel-plugin-prometheus-exporter

๐ŸŸ Mackerel plugin for scraping Prometheus exporter metrics. ๐Ÿ”ฅ
Go
7
star
67

awsrm

Simple AWS Resource "READONLY" Mapper for awspec.
Ruby
7
star
68

jquery-cakephp-debugkit

Add JavaScript valiables panel to 'CakePHP DebugKit'
JavaScript
7
star
69

gh-star-history

:octocat: Show star history of repositories. โญ
Go
7
star
70

tbls-meta

tbls-meta is an external subcommand of tbls for applying metadata managed by tbls to the datasource.
Go
6
star
71

tmpfk

Temporary foreign key add/drop tool for using ERD generator for "Keyless entry (SQL Antipatterns)" schema.
Ruby
6
star
72

DebugMemo

DebugMemo: Memo tool for development / CakePHP plugin
PHP
6
star
73

anything-exuberant-ctags

Exuberant ctags anything.el interface
Emacs Lisp
6
star
74

brewfile-desc

brewfile-desc add descriptions of formulae to Brewfile.
Go
6
star
75

po

CakePHP .po File Edit Plugin
PHP
6
star
76

ghfs

:octocat: Go io/fs implementation for GitHub remote repository
Go
5
star
77

Exception

Exception plugin for CakePHP
PHP
5
star
78

backlog-favicon-changer

Chrome Extension to change favicon for multiple Backlog projects.
JavaScript
5
star
79

emacs-yarm

Yet Another Ruby on Rails Minor Mode for Emacs
Emacs Lisp
5
star
80

calendar

Calendar plugin for CakePHP
PHP
5
star
81

anything-replace-string

replace-string() and query-string() `anything.el' interface
Emacs Lisp
5
star
82

calver

calver is a package/tool provides the ability to work with Calendar Versioning in Go.
Go
5
star
83

ssh_config_to_vuls_config

sc2vc: ssh_config to vuls config TOML format
Ruby
5
star
84

phpenv-nginx-ansible-vagrant

Ruby
5
star
85

typd

ใŠๅ‰ใฏไปŠใพใงๅ…ฅๅŠ›ใ—ใŸใƒ•ใ‚ฉใƒผใƒ ใฎๅ€คใ‚’่ฆšใˆใฆใ„ใ‚‹ใฎใ‹?
JavaScript
5
star
86

Setting

Database driven setting plugin for CakePHP.
PHP
5
star
87

backslack

Bridge between Backlog and Slack
JavaScript
5
star
88

anything-hatena-bookmark

Hatena::Bookmark anything.el interface
Emacs Lisp
5
star
89

Yasd

Yet Another SoftDeletable Behavior for CakePHP
PHP
5
star
90

tbls-build

tbls-build is an external subcommand of tbls for customizing config file of tbls using other tbls.yml or schema.json.
Go
5
star
91

curlreq

curlreq creates *http.Request from curl command.
Go
4
star
92

Sample-Calendar-Application

Sample Application for the CakePHP Calendar Plugin
PHP
4
star
93

repin

repin is a tool to replace strings between keyword pair.
Go
4
star
94

lrep

lrep = l/re/p = line regular expression parser
Go
4
star
95

webroot_view

CakePHP library for use elements and helpers under app/webroot/
PHP
4
star
96

Back

Sessoin base `history back' plugin for CakePHP
PHP
4
star
97

keyp

keyp is a tool to keep public keys up to date.
Go
4
star
98

property-enum

Property based enum plugin for CakePHP 3
PHP
4
star
99

slkm

slkm is github.com/slack-go/slack wrapper package for posting message.
Go
4
star
100

emacs-key-cast

Key Storke Casting Minor Mode for Emacs
4
star