Home

Awesome

ghs

Build Status Coverage Status Go Report Card

ghs - command-line utility for searching Github repositoy.

Trial

ghs trial page

ghs options

[sona ~]$ ghs --help
Usage:
  ghs [OPTION] "QUERY"

Application Options:
  -f, --fields=     limits what fields are searched. 'name', 'description', or 'readme'. (default: name,description)
  -k, --fork=       Forked repositories included in results. 'true', 'only' or 'false'.
  -s, --sort=       The sort field. 'stars', 'forks', or 'updated'. (default: best match)
  -o, --order=      The sort order. 'asc' or 'desc'. (default: desc)
  -l, --language=   searches repositories based on the language they’re written in.
  -u, --user=       limits searches to a specific user name.
  -r, --repo=       limits searches to a specific repository.
  -m, --max=        limits number of result. range 1-1000 (default: 100)
  -v, --version     print version infomation and exit.
  -e, --enterprise= search from github enterprise.
  -t, --token=      Github API token to avoid Github API rate limit
  -h, --help        Show this help message

Github search APIv3 QUERY infomation:
   https://developer.github.com/v3/search/
   https://help.github.com/articles/searching-repositories/

Version:
   ghs 0.0.9 (https://github.com/sonatard/ghs.git)

Install

homebrew, linuxbrew

brew install sonatard/tools/ghs

for Windows Releases sonatard/ghs

Usage

basic usage. default search target.(name, description and readme)

ghs "dotfiles"

You can restrict the search to just the repository name.

ghs -f name "dotfiles"

Limits searches to a specific user.

ghs -f name -u sonatard "dotfiles"
sonatard/dotfiles                       dotfiles

Github Authentication to avoid Github API rate limit

Priority of authentication token

  1. Exec ghs with -t or --token option
$ ghs -t "....."
  1. GITHUB_TOKEN environmental variable
$ export GITHUB_TOKEN="....."
  1. github.token in gitconfig
$ git config --global github.token "....."

Search Github repository and git clone

with motemen/ghq and peco/peco

ghs QUERY | peco | awk '{print $1}' | ghq import

create zsh function

function gpi () {
  [ "$#" -eq 0 ] && echo "Usage : gpi QUERY" && return 1
  ghs "$@" | peco | awk '{print $1}' | ghq import
}

gpi usage

gpi dotfiles

Remove local repository

function gpr () {
  ghq list --full-path | peco | xargs rm -ir
}
gpr

Search Github repository and open with browser

function gho () {
  [ "$#" -eq 0 ] && echo "Usage : gho QUERY" && return 1
  ghs "$@" | peco | awk '{print "https://github.com/"$1}' | xargs open
}
gho dotfiles

Contributors

kou-m

Author

sonatard