
リモートリポジトリのローカルクローンをシンプルに管理するghqの導入とpeco連携について
ghqとは?
作者であるmotemenさんのブログを参照
インストール
$ brew tap motemen/ghq $ brew install ghq
機能抜粋
version
$ ghq -v ghq version 0.7.1
ghq の root を確認
$ ghq root /Users/tbpgr/.ghq
ghq で repositoy を get
$ ghq get tbpgr/crystal_samples
clone https://github.com/tbpgr/crystal_samples -> /Users/tbpgr/.ghq/github.com/tbpgr/crystal_samples
git clone https://github.com/tbpgr/crystal_samples /Users/tbpgr/.ghq/github.com/tbpgr/crystal_samples
Cloning into '/Users/tbpgr/.ghq/github.com/tbpgr/crystal_samples'...
remote: Counting objects: 512, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 512 (delta 0), reused 0 (delta 0), pack-reused 508
Receiving objects: 100% (512/512), 47.97 KiB | 0 bytes/s, done.
Resolving deltas: 100% (186/186), done.
Checking connectivity... done.
$ ghq get tbpgr/eto
clone https://github.com/tbpgr/eto -> /Users/tbpgr/.ghq/github.com/tbpgr/eto
git clone https://github.com/tbpgr/eto /Users/tbpgr/.ghq/github.com/tbpgr/eto
Cloning into '/Users/tbpgr/.ghq/github.com/tbpgr/eto'...
remote: Counting objects: 63, done.
remote: Total 63 (delta 0), reused 0 (delta 0), pack-reused 63
Unpacking objects: 100% (63/63), done.
Checking connectivity... done.
ghq で管理しているリポジトリの一覧表示
$ ghq list github.com/tbpgr/crystal_samples github.com/tbpgr/eto
ghq で管理しているリポジトリへの移動
$ ghq look tbpgr/crystal_samples
cd /Users/tbpgr/.ghq/github.com/tbpgr/crystal_samples
~/.ghq/github.com/tbpgr/crystal_samples
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
~/.ghq/github.com/tbpgr/crystal_samples
peco 連携
preztoのgit moduleにgcd functionを追加してみます。
(この作法が正しいのか動か把握できてない・・・)
- ~/.zprezto/modules/git/gcd
function gcd() {
local selected_repo=$(ghq list -p | peco)
if [ -n "$selected_repo" ]; then
cd $selected_repo
fi
}
