From 0f2782f7b9419412d8b0c9a62060e8c07b375b22 Mon Sep 17 00:00:00 2001 From: nyatinte Date: Sun, 8 Mar 2026 22:12:05 +0900 Subject: [PATCH 1/5] perf(zsh): defer redundant startup initialization to shorten shell startup Zsh startup was paying for duplicate compinit work and eager loading of abbr-related plugins before the first prompt appeared. Let Sheldon own compinit, keep git-gtr completion discoverable via zstyle, defer abbr-related plugins, and only source Docker Desktop init when the script exists so interactive startup does less synchronous work. --- home/dot_config/sheldon/plugins.toml | 2 ++ home/dot_zsh.d/dev-tools.zsh | 4 ++-- home/dot_zshrc | 9 ++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/home/dot_config/sheldon/plugins.toml b/home/dot_config/sheldon/plugins.toml index 39d6915..43a06e0 100644 --- a/home/dot_config/sheldon/plugins.toml +++ b/home/dot_config/sheldon/plugins.toml @@ -18,6 +18,7 @@ defer = "{{ hooks?.pre | nl }}{% for file in files %}zsh-defer source \"{{ file # [plugins.zsh-abbr] github = "olets/zsh-abbr" +apply = ["defer"] [plugins.zsh-abbr.hooks] pre = ''' @@ -43,6 +44,7 @@ github = "zdharma-continuum/fast-syntax-highlighting" # [plugins.fast-abbr-highlighting] github = "5A6F65/fast-abbr-highlighting" +apply = ["defer"] # [plugins.zsh-completions] diff --git a/home/dot_zsh.d/dev-tools.zsh b/home/dot_zsh.d/dev-tools.zsh index 1972208..24db726 100644 --- a/home/dot_zsh.d/dev-tools.zsh +++ b/home/dot_zsh.d/dev-tools.zsh @@ -5,7 +5,7 @@ export PROTO_AUTO_INSTALL=true export PATH="$PROTO_HOME/tools/node/globals/bin:$PATH" # Docker Desktop -source "$HOME/.docker/init-zsh.sh" || true +[ -r "$HOME/.docker/init-zsh.sh" ] && source "$HOME/.docker/init-zsh.sh" # ni - package manager export NI_DEFAULT_AGENT="pnpm" @@ -16,4 +16,4 @@ export VISUAL="cursor" export EDITOR="hx" # Lazygit -export LG_CONFIG_FILE="$HOME/.config/lazygit/config.yml" \ No newline at end of file +export LG_CONFIG_FILE="$HOME/.config/lazygit/config.yml" diff --git a/home/dot_zshrc b/home/dot_zshrc index b78faa4..5e04962 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -5,16 +5,15 @@ ZSH_CONFIG_DIR="${HOME}/.zsh.d" # 各設定ファイルを読み込み source "${ZSH_CONFIG_DIR}/path.zsh" -# 補完システムの初期化(compdef を使うsourceより前に実行) -fpath+=(${ZSH_CONFIG_DIR}/completions) -autoload -Uz compinit && compinit +# 補完関数の探索先。実際の compinit は sheldon 側で 1 回だけ実行する。 +fpath+=("${ZSH_CONFIG_DIR}/completions") +# `git gtr` を git サブコマンド補完に出すための zstyle だけ先に登録する。 +zstyle ':completion:*:*:git:*' user-commands gtr:'Git worktree management' source "${ZSH_CONFIG_DIR}/dev-tools.zsh" source "${ZSH_CONFIG_DIR}/fzf.zsh" [ -f "${ZSH_CONFIG_DIR}/.local.zsh" ] && source "${ZSH_CONFIG_DIR}/.local.zsh" -source "${ZSH_CONFIG_DIR}/completions/_git-gtr" - # Sheldon eval "$(sheldon source)" From f7cf92af508dba8138697998b078f9a7a78f1bc6 Mon Sep 17 00:00:00 2001 From: nyatinte Date: Sun, 8 Mar 2026 22:13:26 +0900 Subject: [PATCH 2/5] fix(zsh): stop helpers after failed directory changes The fzf directory picker and gwn helper assumed cd would always succeed. Returning early avoids continuing with a stale prompt state or half-finished helper flow when the target directory no longer exists or cannot be entered. --- home/dot_zsh.d/fzf.zsh | 2 +- home/dot_zsh.d/utils.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/home/dot_zsh.d/fzf.zsh b/home/dot_zsh.d/fzf.zsh index b3cb2a6..2ad7c4d 100644 --- a/home/dot_zsh.d/fzf.zsh +++ b/home/dot_zsh.d/fzf.zsh @@ -47,7 +47,7 @@ function fzf-cd-widget() { ) if [[ -n "$selected" ]]; then - cd "$selected" + cd "$selected" || return fi zle reset-prompt } diff --git a/home/dot_zsh.d/utils.zsh b/home/dot_zsh.d/utils.zsh index fea6502..4cefb75 100644 --- a/home/dot_zsh.d/utils.zsh +++ b/home/dot_zsh.d/utils.zsh @@ -12,7 +12,7 @@ gwn() { : fi fi - git gtr new "$branch_name" --from "origin/$default_branch" && cd "$(git gtr go "$branch_name")" + git gtr new "$branch_name" --from "origin/$default_branch" && cd "$(git gtr go "$branch_name")" || return } # 長時間コマンドの完了通知 From e9ea2cc7cfe755eece0f28cf2250259f8e6fb490 Mon Sep 17 00:00:00 2001 From: nyatinte Date: Sun, 8 Mar 2026 23:09:59 +0900 Subject: [PATCH 3/5] refactor(zsh): remove the unused gwn helper The gwn wrapper is no longer used anywhere in this dotfiles setup. Dropping it reduces dead shell code and removes a helper that still depended on git gtr state even though it is no longer part of the active workflow. --- home/dot_zsh.d/utils.zsh | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/home/dot_zsh.d/utils.zsh b/home/dot_zsh.d/utils.zsh index 4cefb75..71c5da4 100644 --- a/home/dot_zsh.d/utils.zsh +++ b/home/dot_zsh.d/utils.zsh @@ -1,20 +1,3 @@ -# Git worktree runner -- -gwn() { - local branch_name="$1" - if [ -z "$branch_name" ]; then - echo "Usage: gwn " - return 1 - fi - local default_branch - default_branch=$(git remote show origin 2>/dev/null | awk '/HEAD branch/ {print $NF}') - if [ -z "$default_branch" ] && command -v gh >/dev/null 2>&1; then - if default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name 2>/dev/null); then - : - fi - fi - git gtr new "$branch_name" --from "origin/$default_branch" && cd "$(git gtr go "$branch_name")" || return -} - # 長時間コマンドの完了通知 notify-after() { "$@" From e9f69fa9ac01b87db7aec38ec6a1168c24769701 Mon Sep 17 00:00:00 2001 From: nyatinte Date: Sun, 8 Mar 2026 23:21:21 +0900 Subject: [PATCH 4/5] refactor(zellij): remove the unused project-launch shortcut The Alt-b binding only launched a dedicated project helper script, and that shortcut is no longer part of the active workflow. Removing the keybind together with its script keeps the Zellij config smaller and avoids carrying an unmaintained project launcher path. --- home/dot_config/zellij/config.kdl | 8 -------- home/scripts/executable_zellij-new-branch-tab.sh | 15 --------------- 2 files changed, 23 deletions(-) delete mode 100644 home/scripts/executable_zellij-new-branch-tab.sh diff --git a/home/dot_config/zellij/config.kdl b/home/dot_config/zellij/config.kdl index 6eb603b..8bee960 100644 --- a/home/dot_config/zellij/config.kdl +++ b/home/dot_config/zellij/config.kdl @@ -1,9 +1 @@ theme "solarized-dark" - -keybinds { - normal { - bind "Alt b" { - Run "bash" "-c" "$HOME/scripts/zellij-new-branch-tab.sh"; - } - } -} diff --git a/home/scripts/executable_zellij-new-branch-tab.sh b/home/scripts/executable_zellij-new-branch-tab.sh deleted file mode 100644 index 83718f6..0000000 --- a/home/scripts/executable_zellij-new-branch-tab.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -branch_name=$(git branch --show-current 2>/dev/null || echo "worktree") -current_dir=$(pwd) - -zellij action new-tab --name "$branch_name" -zellij action write-chars "cd \"$current_dir\" && cc" -zellij action write 10 -zellij action new-pane --direction right --cwd "$current_dir" -zellij action write-chars "cd \"$current_dir\"" -zellij action write 10 -zellij action focus-previous-pane -zellij action rename-pane "claude" -zellij action focus-next-pane -zellij action rename-pane "claude" From d9adec83662d09033b81d2444314d2dd127746a8 Mon Sep 17 00:00:00 2001 From: nyatinte Date: Thu, 12 Mar 2026 02:13:00 +0900 Subject: [PATCH 5/5] fix(zsh): redraw the prompt after failed fzf directory jumps The earlier safety guard returned immediately when cd failed inside fzf-cd-widget. Resetting the prompt before returning keeps the widget behavior tidy even when the selected directory disappeared or cannot be entered. --- home/dot_zsh.d/fzf.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home/dot_zsh.d/fzf.zsh b/home/dot_zsh.d/fzf.zsh index 2ad7c4d..8de6757 100644 --- a/home/dot_zsh.d/fzf.zsh +++ b/home/dot_zsh.d/fzf.zsh @@ -47,7 +47,10 @@ function fzf-cd-widget() { ) if [[ -n "$selected" ]]; then - cd "$selected" || return + cd "$selected" || { + zle reset-prompt + return + } fi zle reset-prompt }