• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Shell
  • License
    ISC License
  • Created over 10 years ago
  • Updated about 5 years ago

Reviews

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

Repository Details

Easily manage your local git repos

gh

gh allows you to very quickly navigate between GitHub project cloned on your local box. It will cd into project directories quickly and clone repos that do not exist.

There is a lot of mental overhead trying to manage a custom ~/src directory with your projects. I tried managing by work/personal, programming language, even tried a different directory for each month. I found by simply making your projects path reflect GitHub, it was much easier to remember where things were.

Here is a demo of me moving around various projects

demo

Usage

Clone and/or go to ~/src/github.com/githubuser/githubrepo.

gh githubuser githubrepo

It'll either just be a cd or it will clone [email protected]:githubuser/githubrepo.git

Note that tab completion is available for project and usernames.

Changing the base directory

gh will clone or cd into $GH_BASE_DIR/github.com/user/repo. By default $GH_BASE_DIR points to $HOME/src. By changing the $GH_BASE_DIR variable in your shell's config file, you can control where gh will clone/cd into.

Note: Already cloned repos will not be transferred to the new location, they will be cloned again.

More important Note: Do not use the tilde-character (~) in $GH_BASE_DIR, use $HOME instead.

Supported Shells

Installation for bash

echo 'source ~/src/github.com/jdxcode/gh/bash/gh.bash' >> ~/.bashrc
echo 'source ~/src/github.com/jdxcode/gh/completions/gh.bash' >> ~/.bashrc

Installation For Fish

Using oh-my-fish:

omf install gh

Using fisherman:

fisher jdxcode/gh

Alternatively, symlink (or copy) the function and completion files into $fish_function_path and $fish_complete_path

mkdir -p ~/src/github.com/jdxcode
git clone [email protected]:jdxcode/gh.git ~/src/github.com/jdxcode/gh
ln -s ~/src/github.com/jdxcode/gh/functions/gh.fish ~/.config/fish/functions/gh.fish
ln -s ~/src/github.com/jdxcode/gh/completions/gh.fish ~/.config/fish/completions/gh.fish

Installation For Oh-My-ZSH

Add this environment variable for your GitHub username (optional)

typeset +gx -A GITHUB
GITHUB[user]=jdxcode

Then symlink (or copy) the gh folder into your Oh-My-ZSH plugins folder

ln -s ~/src/github.com/jdxcode/gh/zsh/gh ~/.oh-my-zsh/custom/plugins/gh

Next add the plugin to your ~/.zshrc file

plugins=(gh)

For example:

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git brew meteor node npm osx redis-cli sublime gh)

Finally reload the ~/.zshrc file:

source ~/.zshrc

The zsh autocompletion supports loading a user's repositories from github. For that to work, you need to set the environment variable GH_FETCH_REPOS to true. You will also need to install jsawk for it to work.

If you now type gh someusername and then press <Tab>, it will load that user's repositories from github and display them to you.

Note that, if autocompletion isn't working, then you probably need to make zsh refresh the completions dumpfile. Just remove the $HOME/.zcompdump-* file:

rm $HOME/.zcompdump-*

and reload the ~/.zshrc again to regenerate it.

For the bb (bitbucket) equivalent, repeat the above instructions, but substitute gh with bb, i.e.:

ln -s ~/src/github.com/jdxcode/gh/zsh/bb ~/.oh-my-zsh/custom/plugins/bb
plugins=(gh bb)
source ~/.zshrc

As before for GITHUB environment variable, the environment variable BITBUCKET is optional:

typeset +gx -A BITBUCKET
BITBUCKET[user]=jdxcode

Installation for zsh

Zsh supports bash autocomplete. You can add the following to your .zshrc but make sure you have compinit done first.

compinit
...
# bash completion and gh
autoload bashcompinit
bashcompinit
source ~/src/github.com/jdxcode/gh/bash/gh.bash
source ~/src/github.com/jdxcode/gh/completions/gh.bash

GitHub Alternatives

  • bb - bitbucket (fish)
  • gl - gitlab (fish, bash)

Go developers

This follows the standard convention for Go projects so long as you have your GOPATH set to ~.

More Repositories

1

rtx

Runtime Executor (asdf rust clone)
Rust
1,998
star
2

npm-register

Your own private npm registry and backup server
JavaScript
483
star
3

mean-sample

Sample project for Write Modern Web Apps with the MEAN Stack by Jeff Dickey
JavaScript
165
star
4

ng-modules

Example Angular app with Gulp concatenation
JavaScript
138
star
5

node-sample

how to use node in production
JavaScript
138
star
6

angular-boilerplate

example angular app
JavaScript
77
star
7

tmux-spotify-info

Shows current song playing on spotify in your tmux status line
AppleScript
75
star
8

go-netrc

Golang netrc parser
Go
42
star
9

tmux-weather

Show weather in tmux status line. No powerline needed.
JavaScript
34
star
10

demand

prompt library for rust
Rust
31
star
11

chim

Cross-platform binary shims with optional remote fetching.
Rust
27
star
12

callinwithus

Super simple conference calling application
Ruby
25
star
13

password-prompt

Node cross-platform password prompt
JavaScript
20
star
14

stdout-stderr

mock stdout and stderr
TypeScript
15
star
15

ng-async

JavaScript
13
star
16

qqjs

TypeScript
13
star
17

crm_angular

CSS
13
star
18

crm_perf

A demo CRM for my talk on "The Thick Front-End"
13
star
19

smooth-progress

pixel-by-pixel node progress bar
JavaScript
11
star
20

node-netrc-parser

netrc parser for node.js
TypeScript
9
star
21

tmux-cpu-info

Shows a tiny bar in your tmux statusline with the current CPU usage
Python
9
star
22

status.vim

Better status bar
Vim Script
8
star
23

mise-docs

TypeScript
7
star
24

golock

Cross-platform lockfile library for Go
Go
6
star
25

rtx-action

TypeScript
5
star
26

simple-mean

Simple MEAN stack app.
JavaScript
5
star
27

mean-video

4
star
28

heroku-production-check

JavaScript
4
star
29

vim-archive

My vim configuration
Vim Script
4
star
30

oclif-example-dynamic-commands

TypeScript
3
star
31

gode

gode runs a sandboxed node installation to run node code and install npm packages
Go
3
star
32

rtx-docs

Shell
3
star
33

activemonitor

What gets measured gets improved.
Ruby
3
star
34

fs-extra-debug

Monitor fs-extra calls. Uses the debug module.
JavaScript
3
star
35

blog-old

Ruby
2
star
36

wheeler_board

Ruby
2
star
37

connecc

Ruby
2
star
38

nearest-islander

The nearest islander problem
Python
2
star
39

social-app

JavaScript
2
star
40

twentyone

Twenty One Day Habit
Ruby
2
star
41

rtx.jdxcode.com

Shell
2
star
42

htpasswd-auth

read/write htpasswd files for node
JavaScript
2
star
43

backbone_blog

Testing out backbone.js with rails 3.1
2
star
44

crm_node

CoffeeScript
2
star
45

ga-node-hapi-sequelize-example

JavaScript
2
star
46

homebrew-tap

Ruby
2
star
47

jdx-csv-lint

a basic csv linter
Rust
1
star
48

crm_scala

Scala
1
star
49

todo-pyramid

1
star
50

painting-gallery

Ruby
1
star
51

heroku-plugin-readme-generator

JavaScript
1
star
52

json-api-rails

Ruby
1
star
53

crm_rails_jquery

Ruby
1
star
54

oclif-debug

Shell
1
star
55

omniauth-tapjoy

A client to connect to Tapjoy
Ruby
1
star
56

cachejs

Client-side caching
CoffeeScript
1
star
57

girltalk

Ruby
1
star
58

crm_rails

an example app using all postbacks
Ruby
1
star
59

snoresquare

Ruby
1
star
60

edon

Rust
1
star
61

todo

Ruby
1
star
62

heroku-test-1

JavaScript
1
star
63

brogrammers

Ruby
1
star
64

rsvp-checkoff

JavaScript
1
star
65

tumblr

1
star
66

reflix

Ruby
1
star
67

latlon

CLI to get current latitude and longitude on macOS
Swift
1
star
68

todone

Ruby
1
star
69

sort-pjson

JavaScript
1
star
70

nd

Go
1
star
71

annoyingly

Ruby
1
star
72

mean-video-12

JavaScript
1
star
73

Oilzilla

JavaScript
1
star
74

arcanist-vscode

TypeScript
1
star
75

oclifconf

HTML
1
star
76

rtx-python-tox-test

sample project using rtx's venv feature with tox
Python
1
star
77

jdxcode

1
star
78

cli-hubot

CoffeeScript
1
star
79

meep

TypeScript
1
star
80

githubmarkdown

Parses markdown via the Github API
Go
1
star
81

coffee_lunch_beer

Ruby
1
star
82

fish_prompt

Shell
1
star
83

mirror

Ruby
1
star
84

sinatra-examples

some basic examples of building webapps with sinatra
HTML
1
star
85

xxx_fish_prompt

Shell
1
star
86

mail-forward

Go
1
star
87

tmux-battery

Shell
1
star
88

astro_nvim_config

Lua
1
star
89

dickeytk.github.com

JavaScript
1
star
90

rtx-shorthands

Shell
1
star
91

pipeit

JavaScript
1
star
92

git-ps1

git-augmented PS1 for BASH
Shell
1
star
93

startupbowl

Fantasy football for startups.
Ruby
1
star