流行に乗り遅れた感があるけど、今更ながらghq+pecoを使った環境を整えてみたいと思います。
Mac yosemiteでやってみました。
Goのインストール
まずはgoをインストールしましょう、
$ brew install go
簡単です。
ghqのインストール
$ go get github.com/motemen/ghq
ghqのパスを通す
.zshrc
や.bash_profile
などに以下を記述しましょう。
私はzshだったので.zshrcです。
### GO PATH
export GOPATH=$HOME/.go
export PATH=$HOME/.go/bin:$PATH
sourceコマンドで適用します。
$ source ~/.zshrc
ghqコマンドが使えるようになります。
$ ghq
NAME:
ghq - Manage GitHub repository clones
USAGE:
ghq [global options] command [command options] [arguments...]
VERSION:
HEAD
AUTHOR:
motemen - <motemen@gmail.com>
COMMANDS:
get Clone/sync with a remote repository
list List local repositories
look Look into a local repository
import Bulk get repositories from stdin
root Show repositories' root
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
場所はここです。
$ which ghq
/Users/ユーザー名/.go/bin/ghq
ghqを使う
.gitconfigに追記します。
[ghq]
root = ~/.ghq
root = ~/.go/src
私の場合、~/n0bisukeに設置したかったので
[ghq]
root = ~/n0bisuke
root = ~/.go/src
としています。
ここに置いておけばFinderからも確認できるので便利かと思います。
ghq get
でgit cloneできます。 ghq経由でcloneすることで、↑みたいにホスティング先やアカウントごとでリポジトリをいい感じ分類してくれます。
$ ghq get git@github.com:tolabl/HP.git
clone ssh://git@github.com/tolabl/HP.git -> /Users/sugawara_nobisuke/.ghq/github.com/tolabl/HP
git clone ssh://git@github.com/tolabl/HP.git /Users/sugawara_nobisuke/.ghq/github.com/tolabl/HP
Cloning into '/Users/sugawara_nobisuke/.ghq/github.com/tolabl/HP'...
remote: Counting objects: 280, done.
remote: Total 280 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (280/280), 4.70 MiB | 927.00 KiB/s, done.
Resolving deltas: 100% (68/68), done.
Checking connectivity... done.
一覧を見る
$ ghq list
github.com/tolabl/HP
github.com/codegangsta/cli
github.com/daviddengcn/go-colortext
github.com/mitchellh/go-homedir
github.com/motemen/ghq
github.com/motemen/go-colorine
peco
コマンドのログなどをインクリメントサーチしてくれるツール
インストール
$ go get github.com/peco/peco/cmd/peco
簡単ですね。
ghqと組み合わせるとリポジトリ移動がめちゃ便利
$ cd $(ghq list -p | peco)
参考 : http://masteries.papix.net/entry/2014-06-30-ghq.html
まとめ
流行に乗り遅れた感があるけどめちゃ便利ですね
とくにpecoはコマンドのhistoryとかと組み合わせるとかなり便利そうです。