最近数年ぶりにhubを使っている。
以前使っていた時から扱うGitHubリポジトリ数が数倍に増えた今は便利だなーと思う。
で、勤務先ではGitHub Enterpriseを使っているので「hubコマンドをGitHubとGitHub Enterprise両方で使いたい!」という欲求を満たすことにした。
hubコマンドに加えてお世話になるのは以下。
ディレクトリツリーは ghq
にお任せしているのでこのようになる。
$ tree -L 2 .
(ghq root)
├── com.mazgi
│ └── Untitled.mov
├── github.com
│ ├── mazgi
│ ├── mazgi-sandbox
│ └── sbtenv
└── github-enterprise.example.com
├── AI
├── hidenori-matsuki
└── mazgi
そして $(ghq root)/github-enterprise.example.com/.envrc
で次のように $GITHUB_HOST
をexportする。
see: https://hub.github.com/hub.1.html
cat $(ghq root)/github-enterprise.example.com/.envrc
# vim: set filetype=bash
export GITHUB_HOST="github-enterprise.example.com"
これでhubコマンドがGitHub.com/GitHub Enterprise両方とも参照できるようになった。