feat(zsh): carapace でマルチシェル補完に移行 - #77
Merged
Merged
Conversation
zsh の補完エンジンとして carapace を導入する。653 コマンドの spec を 内蔵しており、docker / kubectl / aws / terraform など個別に補完スクリプトを 用意していなかったコマンドもまとめて説明文付きで補完できる。 - dot_Brewfile: carapace を追加 - plugins.toml: 他の補完プラグインより後に carapace を読み込む (compdef を上書きさせるため。syntax-highlighting より前に置く) - plugins.toml: zsh-better-npm-completion を削除(carapace と役割が重複) - custom.zsh: 旧 `npm completion` 生成コードを削除。sheldon より後に 読み込まれて compdef _npm_completion npm で carapace を上書きしていた - dot_zshrc: compinit を先に走らせる理由のコメントを実態に合わせて修正 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
zsh の補完エンジンとして carapace を導入します。653 コマンドの spec を内蔵しているため、これまで個別に補完スクリプトを用意していなかった
docker/kubectl/aws/terraformなどもまとめて説明文付きで補完できるようになります。変更内容
dot_Brewfilebrew "carapace"を追加private_dot_config/sheldon/plugins.toml[plugins.carapace]を追加private_dot_config/sheldon/plugins.tomlzsh-better-npm-completionを削除(carapace と役割が重複)dot_zsh/custom.zshnpm completion生成コード(約60行)を削除dot_zshrc読み込み順について
carapace は約 1000 コマンドに対して
compdefを張るため、他の補完プラグインより後に読み込む必要があります。逆に zsh-syntax-highlighting は最後に置く既存方針を維持したいので、その直前に挿入しています。custom.zsh の npm ブロックを削除した理由
custom.zshはdot_zshrc内で sheldon の後に source されるため、埋め込まれていたcompdef _npm_completion npmが carapace の npm 補完を上書きしていました。carapace 側の spec に統一するために削除します。動作確認
macOS 26.6.1 / zsh 5.9.2 / carapace-bin 1.7.3 で確認。
compdef の登録状況(
zsh -i -cで確認)npm_npm_completion_carapace_completergit_git_carapace_completergh_gh_carapace_completerdocker/kubectl/aws/terraform_carapace_completercompdef 総数: 1992 → 2408
実際の TAB 補完(
zsh/zptyで対話シェルを起動して採取)docker run --r<TAB>で説明文付きの候補が表示されることを確認:起動時間: 0.11 秒(
carapace _carapaceの生成コストは約 10ms、生成されるスクリプトは 51 行)既存チェック:
./shellcheck.shクリーン、tests/*.test.sh11 件すべて pass補足
CARAPACE_EXCLUDES='git,npm'を指定できますCARAPACE_MATCH=1を指定します🤖 Generated with Claude Code