{"id":13558797,"url":"https://github.com/jdx/gh","last_synced_at":"2025-09-17T01:34:17.606Z","repository":{"id":19253799,"uuid":"22489458","full_name":"jdx/gh","owner":"jdx","description":"Easily manage your local git repos","archived":false,"fork":false,"pushed_at":"2024-01-13T05:44:41.000Z","size":2314,"stargazers_count":170,"open_issues_count":7,"forks_count":37,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-30T19:18:55.018Z","etag":null,"topics":["bash","cli","fish","github","zsh"],"latest_commit_sha":null,"homepage":"https://medium.com/@jdxcode/the-best-code-ive-ever-written-afaf96f49535","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdx.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":"2014-07-31T23:59:26.000Z","updated_at":"2024-12-05T22:20:27.000Z","dependencies_parsed_at":"2024-06-16T18:40:49.959Z","dependency_job_id":null,"html_url":"https://github.com/jdx/gh","commit_stats":null,"previous_names":["jdxcode/gh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdx%2Fgh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdx%2Fgh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdx%2Fgh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdx%2Fgh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdx","download_url":"https://codeload.github.com/jdx/gh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232704333,"owners_count":18563734,"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":["bash","cli","fish","github","zsh"],"created_at":"2024-08-01T12:05:09.684Z","updated_at":"2025-09-17T01:34:12.246Z","avatar_url":"https://github.com/jdx.png","language":"Shell","readme":"gh\n==\n\ngh allows you to very quickly navigate between GitHub project cloned on your\nlocal box. It will `cd` into project directories quickly and clone repos that do\nnot exist.\n\nThere 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.\n\nHere is a demo of me moving around various projects\n\n![demo](demo.gif)\n\n\u003c!-- toc --\u003e\n\n- [Usage](#usage)\n  * [Changing the base directory](#changing-the-base-directory)\n- [Supported Shells](#supported-shells)\n- [Installation for bash](#installation-for-bash)\n- [Installation For Fish](#installation-for-fish)\n- [Installation For Oh-My-ZSH](#installation-for-oh-my-zsh)\n- [Installation for zsh](#installation-for-zsh)\n- [GitHub Alternatives](#github-alternatives)\n- [Go developers](#go-developers)\n\n\u003c!-- tocstop --\u003e\n\nUsage\n=====\n\nClone and/or go to `~/src/github.com/githubuser/githubrepo`.\n\n```\ngh githubuser githubrepo\n```\n\nIt'll either just be a `cd` or it will clone `git@github.com:githubuser/githubrepo.git`\n\nNote that tab completion is available for project and usernames.\n\n## Changing the base directory\n`gh` will clone or `cd` into `$GH_BASE_DIR/github.com/user/repo`.\nBy 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.\n\n**Note:** Already cloned repos will not be transferred to the new location, they will be cloned again.\n\n**More important Note:** Do not use the tilde-character (`~`) in `$GH_BASE_DIR`, use `$HOME` instead.\n\nSupported Shells\n================\n\n* bash\n* [fish](http://fishshell.com/)\n* [OH-MY-ZSH](http://ohmyz.sh/)\n* zsh\n\nInstallation for bash\n=====================\n\n```\necho 'source ~/src/github.com/jdxcode/gh/bash/gh.bash' \u003e\u003e ~/.bashrc\necho 'source ~/src/github.com/jdxcode/gh/completions/gh.bash' \u003e\u003e ~/.bashrc\n```\n\nInstallation For Fish\n=====================\n\nUsing [oh-my-fish](https://github.com/oh-my-fish/oh-my-fish):\n\n```\nomf install gh\n```\n\nUsing [fisherman](https://github.com/fisherman/fisherman):\n\n```\nfisher jdxcode/gh\n```\n\nAlternatively, symlink (or copy) the function and completion files into `$fish_function_path` and `$fish_complete_path`\n\n    mkdir -p ~/src/github.com/jdxcode\n    git clone git@github.com:jdxcode/gh.git ~/src/github.com/jdxcode/gh\n    ln -s ~/src/github.com/jdxcode/gh/functions/gh.fish ~/.config/fish/functions/gh.fish\n    ln -s ~/src/github.com/jdxcode/gh/completions/gh.fish ~/.config/fish/completions/gh.fish\n\nInstallation For Oh-My-ZSH\n==========================\n\nAdd this environment variable for your GitHub username (optional)\n\n    typeset +gx -A GITHUB\n    GITHUB[user]=jdxcode\n\nThen symlink (or copy) the gh folder into your Oh-My-ZSH plugins folder\n\n    ln -s ~/src/github.com/jdxcode/gh/zsh/gh ~/.oh-my-zsh/custom/plugins/gh\n\nNext add the plugin to your `~/.zshrc` file\n\n    plugins=(gh)\n\nFor example:\n\n```\n# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)\n# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/\n# Example format: plugins=(rails git textmate ruby lighthouse)\nplugins=(git brew meteor node npm osx redis-cli sublime gh)\n\n```\n\nFinally reload the `~/.zshrc` file:\n\n    source ~/.zshrc\n\nThe 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](https://github.com/micha/jsawk) for it to work.\n\nIf you now type `gh someusername` and then press `\u003cTab\u003e`, it will load that user's repositories from github and display them to you.\n\nNote that, if autocompletion isn't working, then you probably need to make zsh refresh the completions dumpfile. Just remove the `$HOME/.zcompdump-*` file:\n\n    rm $HOME/.zcompdump-*\n\nand reload the `~/.zshrc` again to regenerate it.\n\nFor the `bb` (bitbucket) equivalent, repeat the above instructions, but substitute `gh` with `bb`, i.e.:\n\n    ln -s ~/src/github.com/jdxcode/gh/zsh/bb ~/.oh-my-zsh/custom/plugins/bb\n    plugins=(gh bb)\n    source ~/.zshrc\n\nAs before for `GITHUB` environment variable, the environment variable `BITBUCKET` is optional:\n\n    typeset +gx -A BITBUCKET\n    BITBUCKET[user]=jdxcode\n\n\nInstallation for zsh\n==========================\nZsh supports bash autocomplete. You can add the following to your .zshrc but make sure you have `compinit` done first.\n```\ncompinit\n...\n# bash completion and gh\nautoload bashcompinit\nbashcompinit\nsource ~/src/github.com/jdxcode/gh/bash/gh.bash\nsource ~/src/github.com/jdxcode/gh/completions/gh.bash\n```\n\nGitHub Alternatives\n===================\n\n* bb - bitbucket (fish)\n* gl - gitlab (fish, bash)\n\nGo developers\n=============\n\nThis follows the standard convention for Go projects so long as you have your `GOPATH` set to `~`.\n","funding_links":[],"categories":["Shell","github"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdx%2Fgh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdx%2Fgh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdx%2Fgh/lists"}