Conversation
…tories - core/path.zsh: PATH management (consolidated from path.zsh + dev-tools.zsh) - core/env.zsh: environment variables (EDITOR, NI_*, LG_CONFIG_FILE) - tools/proto.zsh, docker.zsh, fzf.zsh, vite-plus.zsh: per-tool activation - functions/git.zsh, notify.zsh: utility functions split by domain https://claude.ai/code/session_01GkwneqBX3TWvXCVmAsAU33
…acket style - Remove self-documenting comments from env.zsh, docker.zsh, vite-plus.zsh - Use (N) glob qualifier in functions loop to handle empty directory safely - Standardize to [[ ]] throughout (was mixing [ ] for .local.zsh) https://claude.ai/code/session_01GkwneqBX3TWvXCVmAsAU33
There was a problem hiding this comment.
Code Review
This pull request refactors the Zsh configuration by modularizing settings into dedicated directories for core environment variables, tools, and functions. The .zshrc file has been updated to source these new locations, including a dynamic loop for loading functions. Feedback includes a suggestion to improve the notify-after function by displaying the full command string instead of just the first argument, and a recommendation to use a similar loop for sourcing tool configurations to enhance maintainability.
| if [ $exit_code -eq 0 ]; then | ||
| cmux notify --title "✓ Command Complete" --body "$1" | ||
| else | ||
| cmux notify --title "✗ Command Failed" --body "$1 (exit $exit_code)" | ||
| fi |
There was a problem hiding this comment.
The notification currently only shows the first argument of the command (e.g., sleep instead of sleep 10). Using "$*" will provide the full command string in the notification body, making it much more informative for the user.
if [ $exit_code -eq 0 ]; then
cmux notify --title "✓ Command Complete" --body "$*"
else
cmux notify --title "✗ Command Failed" --body "$* (exit $exit_code)"
fi
There was a problem hiding this comment.
| source "${ZSH_CONFIG_DIR}/tools/proto.zsh" | ||
| source "${ZSH_CONFIG_DIR}/tools/docker.zsh" | ||
| source "${ZSH_CONFIG_DIR}/tools/fzf.zsh" | ||
| source "${ZSH_CONFIG_DIR}/tools/vite-plus.zsh" |
There was a problem hiding this comment.
To improve maintainability and consistency with how functions are loaded (lines 24-26), consider using a loop to source all files in the tools/ directory. This allows for adding or removing tool configurations without needing to manually update .zshrc each time.
for f in "${ZSH_CONFIG_DIR}/tools/"*.zsh(N); do
source "$f"
done
There was a problem hiding this comment.
tools/ はロード順に意味があります(core/env.zsh で設定した変数を proto.zsh が参照するなど)。グロブによるアルファベット順読み込みでは順序が保証できないため、今回は明示的 source を維持します。
Generated by Claude Code
Ensures chezmoi apply cleans up old files from ~/.zsh.d/: - remove_path.zsh → deletes ~/.zsh.d/path.zsh - remove_dev-tools.zsh → deletes ~/.zsh.d/dev-tools.zsh - remove_fzf.zsh → deletes ~/.zsh.d/fzf.zsh - remove_utils.zsh → deletes ~/.zsh.d/utils.zsh https://claude.ai/code/session_01GkwneqBX3TWvXCVmAsAU33
There was a problem hiding this comment.
Pull request overview
zsh 設定ファイルを責務ごとにディレクトリ分割し、.zshrc から新構成を読み込むように整理するPRです(Vite+ の env 読み込みは存在チェック付きに変更)。
Changes:
~/.zsh.dをcore/,tools/,functions/に再編し、.zshrcの読み込み順・対象を更新- PATH/環境変数を
core/path.zsh,core/env.zshに分離し、ツール設定をtools/配下へ移動 notify-afterをfunctions/notify.zshに分離し、関数ファイルをグロブで自動読み込み
Reviewed changes
Copilot reviewed 8 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| home/dot_zshrc | 新ディレクトリ構成に合わせて core/tools/functions を読み込むよう変更 |
| home/dot_zsh.d/core/path.zsh | PATH 管理を配列 + typeset -U で一元化 |
| home/dot_zsh.d/core/env.zsh | エディタ/ni/lazygit などの環境変数を分離 |
| home/dot_zsh.d/tools/proto.zsh | proto 有効化設定を分離 |
| home/dot_zsh.d/tools/docker.zsh | Docker init の任意読み込みを分離 |
| home/dot_zsh.d/tools/vite-plus.zsh | Vite+ env を存在チェック付きで読み込み |
| home/dot_zsh.d/tools/fzf.zsh | fzf のキーバインド/ウィジェット設定を独立ファイル化 |
| home/dot_zsh.d/functions/git.zsh | notify-after を分離したため削除 |
| home/dot_zsh.d/functions/notify.zsh | notify-after を新規ファイルとして追加 |
| home/dot_zsh.d/dev-tools.zsh | 旧まとめファイルを削除 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for f in "${ZSH_CONFIG_DIR}/functions/"*.zsh(N); do | ||
| source "$f" | ||
| done |
There was a problem hiding this comment.
The functions autoload loop can behave unexpectedly when the glob matches nothing: in many shells (including zsh), for f in; do ... falls back to iterating over positional parameters. If functions/*.zsh(N) expands to empty (e.g., directory missing/empty), this could end up attempting to source arbitrary shell args. Consider guarding with an explicit existence check (e.g., build an array of matches and only loop when non-empty) or add a [[ -r $f ]] || continue inside the loop.
| for f in "${ZSH_CONFIG_DIR}/functions/"*.zsh(N); do | |
| source "$f" | |
| done | |
| function_files=("${ZSH_CONFIG_DIR}/functions/"*.zsh(N)) | |
| if (( ${#function_files[@]} )); then | |
| for f in "${function_files[@]}"; do | |
| source "$f" | |
| done | |
| fi |
There was a problem hiding this comment.
zsh の (N) glob 修飾子(Null glob)は、マッチするファイルが0件のとき展開結果を空にしてループをスキップします。for f in *.zsh(N) でマッチなしの場合にループ本体は実行されないため、配列化によるガードは不要と判断し現状を維持します。
Generated by Claude Code
| notify-after() { | ||
| "$@" | ||
| local exit_code=$? | ||
| if [ $exit_code -eq 0 ]; then |
There was a problem hiding this comment.
Use of single-bracket test with an unquoted variable is brittle in zsh ([ $exit_code -eq 0 ] can error if the variable is ever empty/non-numeric). Prefer zsh-native arithmetic ((( exit_code == 0 ))) or [[ $exit_code -eq 0 ]] for a more robust numeric check.
| if [ $exit_code -eq 0 ]; then | |
| if (( exit_code == 0 )); then |
There was a problem hiding this comment.
- (( exit_code == 0 )) is more robust than [ \$exit_code -eq 0 ] in zsh - \$* shows full command (e.g. "sleep 10") instead of just first arg https://claude.ai/code/session_01GkwneqBX3TWvXCVmAsAU33
|
@copilot 機能のデグレない? |
機能のデグレはありません。全項目を照合した結果:
意図的な変更(改善)は2点:
|
概要
フラットに並んでいた zsh 設定ファイルを、責務ごとにディレクトリ分けして再編しました。
変更前
dev-tools.zshが proto の起動、Docker 初期化、エディタ設定、パッケージマネージャ設定、Vite+ の読み込みなど、無関係な設定をすべて抱えていた。またpath.zshとdev-tools.zshに PATH 追加が重複していた。変更後
機能差分
リファクタリングにあたり全項目を照合した結果、実質的な挙動の変化は 1点のみ です:
vite-plusの読み込み. "$HOME/.vite-plus/env"(無条件)[[ -f ... ]] && source(存在確認あり)変更前はファイルが存在しない環境でシェル起動がエラー終了するバグがありました。今回の変更で安全になっています。
その他の変更は機能的に同等です:
dev-tools.zshにあったexport PATH="$PROTO_HOME/tools/node/globals/bin:$PATH"はcore/path.zshのtypeset -U path PATH+ path 配列に同エントリが既にあったため、削除しても動作は変わりませんfpath設定より前になりましたが、独立した変数のため影響なしその他の改善点
functions/はグロブ(*.zsh(N))で読み込むため、新しい関数ファイルを置くだけで自動認識されます(N)glob 修飾子により、functions/が空でもエラーになりません.local.zshの存在チェックを[ -f ]から[[ -f ]]に統一しました