[[Lazygit]]で[[ある時点のワークツリーを利用 (Lazygit)|ある時点のワークツリーを利用]]したいとき、都度pathの入力が必要だが、`~/worktrees/<repo>/<branch>` のように決まったパスに作成したい。
## 関連issue
要望は挙がっている。
<div class="link-card-v2">
<div class="link-card-v2-site">
<img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" />
<span class="link-card-v2-site-name">GitHub</span>
</div>
<div class="link-card-v2-title">
deafult path for worktrees · Issue #3230 · jesseduffield/lazygit
</div>
<div class="link-card-v2-content">
Is your feature request related to a problem? Please describe. When I create a new worktree, I'm asked to specif ...
</div>
<img class="link-card-v2-image" src="https://opengraph.githubassets.com/895bf78483cf8a7a241b99ff0f7502a0c75be3d87510b72a669d948752bc1d3e/jesseduffield/lazygit/issues/3230" />
<a href="https://github.com/jesseduffield/lazygit/issues/3230"></a>
</div>
## 設定に追加する
[[カスタムコマンドを定義 (Lazygit)|カスタムコマンドを定義]]すればよい。既存のキーマップを上書きする場合。
```yaml
customCommands:
- key: "w"
context: "localBranches"
description: "Create worktree in ~/worktrees/<repo>/<branch>"
command: 'repo=$(basename "$(git rev-parse --show-toplevel)"); branch={{.SelectedLocalBranch.Name | quote}}; mkdir -p "$HOME/worktrees/$repo" && git worktree add "$HOME/worktrees/$repo/$branch" "$branch"'
output: "terminal"
```