Branch Colors
Branch Colors picks a color from the current git branch name and paints the VS Code title bar and status bar with it. You can tell which branch you are on at a glance.
Features
- The same branch name always gets the same color, on any PC
- Switching branches changes the color immediately
- You can assign fixed colors by branch name prefix, or choose the colors to pick from
- The text color (white or black) is chosen automatically for readability
Settings
| Setting |
Default |
Description |
branchColors.enabled |
true |
Set to false to remove the colors this extension wrote |
branchColors.prefixColors |
{} |
Fixed colors by branch name prefix. If several prefixes match, the longest one wins |
branchColors.palette |
[] |
Colors to pick from for branches that match no prefix. If empty, one of 12 built-in colors is used |
Colors are written as #rrggbb or #rgb. Invalid values are ignored.
{
"branchColors.prefixColors": {
"main": "#b71c1c",
"feature/": "#1565c0",
"hotfix/": "#e65100"
},
"branchColors.palette": ["#2e7d32", "#6a1b9a", "#00695c"]
}
To use one color for every branch, set the prefix to an empty string: { "": "#455a64" }.
How it works
The extension writes these 6 keys to workbench.colorCustomizations in the workspace settings (.vscode/settings.json). Other keys are left untouched.
titleBar.activeBackground / titleBar.activeForeground
titleBar.inactiveBackground / titleBar.inactiveForeground
statusBar.background / statusBar.foreground
The colors are removed on a detached HEAD, and when branchColors.enabled is false.
Known limitations
- Only the repository of the first workspace folder is watched
- With the built-in 12 colors, different branches can get the same color
- If
.vscode/settings.json is tracked by git, every branch switch creates a diff
- If you wrote the 6 keys above yourself, they are overwritten
- In Restricted Mode, the extension does not run
License
MIT License. See the LICENSE file. src/git.d.ts is copied from microsoft/vscode (MIT License).
Branch Colors
Branch Colors は、現在の git ブランチ名から色を決め、VS Code のタイトルバーとステータスバーを塗り分ける拡張機能です。どのブランチで作業しているかが一目で分かります。
特徴
- 同じブランチ名なら、どの PC でも同じ色になる
- ブランチを切り替えると、すぐに色が変わる
- ブランチ名の前方一致で色を固定したり、選ばれる色の候補を指定したりできる
- 文字色(白か黒)は、読みやすい方を自動で選ぶ
設定
| 設定 |
既定値 |
説明 |
branchColors.enabled |
true |
false にすると、この拡張が書いた色を消す |
branchColors.prefixColors |
{} |
ブランチ名の前方一致と色の組み合わせ。複数当てはまるときは、長く一致した方を使う |
branchColors.palette |
[] |
どの前方一致にも当てはまらないブランチの色の候補。空なら、組み込みの 12 色から選ぶ |
色は #rrggbb か #rgb の形で書きます。形が正しくない値は無視します。
{
"branchColors.prefixColors": {
"main": "#b71c1c",
"feature/": "#1565c0",
"hotfix/": "#e65100"
},
"branchColors.palette": ["#2e7d32", "#6a1b9a", "#00695c"]
}
すべてのブランチを 1 色にしたいときは、前方一致の文字列を空にします({ "": "#455a64" })。
仕組み
ワークスペース設定(.vscode/settings.json)の workbench.colorCustomizations に、次の 6 つのキーを書き込みます。それ以外のキーには触れません。
titleBar.activeBackground / titleBar.activeForeground
titleBar.inactiveBackground / titleBar.inactiveForeground
statusBar.background / statusBar.foreground
detached HEAD のとき、および branchColors.enabled が false のときは、色を消します。
制約
- 監視するのは、最初のワークスペースフォルダのリポジトリだけ
- 組み込みの 12 色を使うと、別のブランチが同じ色になることがある
.vscode/settings.json を git で管理していると、ブランチを切り替えるたびに差分が出る
- 上の 6 つのキーを自分で書いていると、上書きされる
- 制限モードでは動かない
ライセンス
MIT License です。詳細は LICENSE ファイルを参照してください。src/git.d.ts は microsoft/vscode からコピーしたものです(MIT License)。