gwq cd でワークツリー移動時にシェルがネストする問題の解決方法
gwq cd でワークツリー移動時にシェルがネストする問題の解決方法
コーディングエージェントにやさしい環境は、人間にも優しかった ghq × gwq × fzf のススメ の記事を読んで d-kuro/gwq を試したところ、gwq cd コマンドで Warning が出ました。
本記事ではその対処法を紹介します。
問題
以下のようにエイリアスを作成していました。
alias gwc='gwq cd'
この状態で gwc を実行すると、別のシェルが開くようになっていました。
$ gwc
Launching shell in: /Users/<USER_NAME>/workspace/<OWNER_NAME>/<REPOSITORY_NAME>=test
Type 'exit' to return to the previous directory
$ gwc
Warning: Shell nesting depth is 2. You need to type 'exit' 2 time(s) to return to the original shell.
To avoid nesting, use: cd $(gwq get <pattern>)
Launching shell in: /Users/<USER_NAME>/workspace/<OWNER_NAME>/<REPOSITORY_NAME>
Type 'exit' to return to the previous directory
原因
GitHub - d-kuro/gwq: 🌳 Git worktree manager with fuzzy finder - Work on multiple branches simultaneously, perfect for parallel AI coding workflows 🍋 に記載されている通り、gwq cd は新しいシェルを起動する仕様でした。
gwq cdChange to worktree directory by launching a new shell.
# Change to a worktree gwq cd feature # Interactive selection gwq cd
解決方法
自分の環境では、新しいシェルを起動してワークツリーディレクトリに移動する必要はありませんでした。
以下のように、現在のシェルでワークツリーを選択しディレクトリを移動するエイリアスに変更しました。
alias gwc='cd $(gwq get)'
これにより、シェルのネストを避けつつ、インタラクティブにワークツリーを選択して移動できるようになりました。
