LoginSignup
407
348

More than 3 years have passed since last update.

ghqでリポジトリ管理とpeco連携で快適git生活

Last updated at Posted at 2014-10-01

Gitのローカルリポジトリが増えてくるとどういう構成にすればいいか悩むところだけど、ghqとpecoがあれば考える必要がありません。今まで入れてなかった事を後悔するレベル。

ghqインストール

Goがまだ入ってなければGoをインストール

% brew install go

お好みのシェルにパスを設定

export GOPATH=$HOME
export PATH=$PATH:$GOPATH/bin

書いたら読み込む(直で打つも良し)

% source ~/.zshrc

ghqインストール

% brew install ghq

ghqで管理するrootディレクトリを設定(~が展開されないよう'で括ってます)

% git config --global ghq.root '~/src'

ghqをつかう

#cloneする
% ghq get git://github.com/project.git
#ghq管理下のリポジトリを表示
% ghq list
#ghq管理下のリポジトリにcd
% ghq look hoge
        cd /Users/strsk/src/github.com/strsk/dotfiles

pecoと連携

pecoインストール

% brew install peco

ghq list -pで管理しているリポジトリのパスをpecoに渡してcdするファンクションを^]に登録します。keyはas you likeで。

function peco-src () {
  local selected_dir=$(ghq list -p | peco --query "$LBUFFER")
  if [ -n "$selected_dir" ]; then
    BUFFER="cd ${selected_dir}"
    zle accept-line
  fi
  zle clear-screen
}
zle -N peco-src
bindkey '^]' peco-src

書いたら読み込む!

% source ~/.zshrc

あとはターミナルで^]を打てば快適生活のはじまりです。
ghq_peco.png

Special Thanks

ghq: リモートリポジトリのローカルクローンをシンプルに管理する - 詩と創作・思索のひろば (Poetry, Writing and Contemplation)
ghqを使ったローカルリポジトリの統一的・効率的な管理について - delirious thoughts
ghq + peco/percol - Tatsuhiko Miyagawa's blog

407
348
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
407
348