ghq-gh-wiki-clone
June 16, 2026 ยท View on GitHub
A zsh plugin that, after ghq get / ghq clone fetches a repository,
automatically clones its GitHub Wiki (when the wiki has pages) into a
.wiki subdirectory of that repository.
How it works
ghq has no native post-get hook. This plugin wraps the zsh ghq function and
adds post-processing only for the get / clone subcommands (the real binary
is always invoked via command ghq, so there is no recursion).
- Diff
ghq list --full-pathbefore and after the get to find newly cloned repositories. - For each repo whose
originis ongithub.com, derive the wiki URL (<repo>.wiki.git). - Use
git ls-remoteto detect a wiki that actually has pages, then clone it into<repo>/.wiki. - Append
.wiki/to the parent repo's.git/info/excludeso the wiki does not show up ingit status(the tracked.gitignoreis left untouched).
The wiki check does not rely on the GitHub API has_wiki flag: has_wiki can
be true while the wiki has no pages, so the plugin verifies that the wiki is
actually clonable with git ls-remote.
Requirements
- ghq
git- zsh
Installation
zinit
zinit load shmokmt/ghq-gh-wiki-clone
antigen
antigen bundle shmokmt/ghq-gh-wiki-clone
oh-my-zsh
git clone https://github.com/shmokmt/ghq-gh-wiki-clone \
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/ghq-gh-wiki-clone"
# Add ghq-gh-wiki-clone to plugins=(...) in your .zshrc
Manual
source /path/to/ghq-gh-wiki-clone/ghq-gh-wiki-clone.plugin.zsh
Usage
Just use ghq as usual.
ghq get github.com/nvbn/thefuck
# => ghq-gh-wiki-clone: cloning wiki -> <ghq root>/github.com/nvbn/thefuck/.wiki
Nothing happens for repositories without a wiki (or with an empty one).
Subcommands other than get / clone (e.g. ghq list) are passed straight
through.
Syncing an existing repository's wiki
The get / clone wrapper only fires on fresh clones. For a repository you
already have, use ghq-wiki-sync to clone the wiki if it is missing, or pull
the latest pages if it is already there:
ghq-wiki-sync nvbn/thefuck
# first run => ghq-gh-wiki-clone: cloning wiki -> <ghq root>/github.com/nvbn/thefuck/.wiki
# later runs => ghq-gh-wiki-clone: updating wiki -> <ghq root>/github.com/nvbn/thefuck/.wiki
# (git pull --ff-only)
The argument is resolved with ghq list --exact, so a bare project name that
exists under multiple owners is reported as ambiguous rather than acting on the
wrong repo. Qualify it as host/user/project to disambiguate:
ghq-wiki-sync thefuck
# => ghq-wiki-sync: 'thefuck' is ambiguous; qualify it as <host/user/project>:
# /path/to/ghq/github.com/nvbn/thefuck
# /path/to/ghq/github.com/other/thefuck
Note:
ghq-wiki-syncis a one-way (remote โ local), read-only sync. It only clones or pulls (fast-forward only) and never pushes, so any local edits to the wiki are not sent back to GitHub. Treat the cloned wiki as a read-only mirror; if you edit it locally, the next--ff-onlypull may fail.
Limitations
ghq get -u(updating an existing repository) produces no diff inghq list, so the wiki check does not run (it only runs on fresh clones). Useghq-wiki-syncto backfill wikis for repositories you already have.- An empty wiki (enabled but with 0 pages) returns no refs from
git ls-remote, so it is not cloned (by design). - Only
github.comis supported.
License
MIT