From fb622983c417afe6a52b567c53a770b6adbe0045 Mon Sep 17 00:00:00 2001 From: Lauri Gates Date: Wed, 8 Jul 2026 14:33:55 +0300 Subject: [PATCH 1/2] fix(zsh): sort ghsq/ghrb PR picker oldest-to-newest with cursor on oldest Merging PRs in creation order is a safer bet for clean rebase/squash merges. Sorts the shared multi-select PR list by createdAt ascending and swaps --tac for --layout=reverse so the cursor starts on the oldest PR at the top, matching the sort direction. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_019qiQLB35RH1xQ5gd8f9npF --- dot_zshrc.tmpl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index ad0953d5..010ec3f5 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -614,16 +614,18 @@ _gh_batch_merge() { } # fzf multi-select over current-repo PRs → TSV "numtitle" lines for -# the batch engine (empty repo field = current repo). $1 = header verb; -# remaining args = extra fzf flags (e.g. --tac to reverse the list order). +# the batch engine (empty repo field = current repo). List is sorted oldest→ +# newest (safer bet for clean rebase/squash order); $1 = header verb; remaining +# args = extra fzf flags (callers pass --layout=reverse so the cursor starts +# on the oldest PR, at the top, matching the sort direction). _gh_pr_multi_select() { local verb="$1"; shift local -a fzf_extra=("$@") local repo repo=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null) gh pr list --limit 100 \ - --json number,title,headRefName,isDraft,statusCheckRollup,reviewDecision \ - --jq '.[] | [ + --json number,title,headRefName,isDraft,statusCheckRollup,reviewDecision,createdAt \ + --jq 'sort_by(.createdAt) | .[] | [ "#\(.number)", (if .isDraft then "draft" else "ready" end), (if (.statusCheckRollup | length) == 0 then "⏳CI" @@ -655,7 +657,7 @@ _gh_pr_multi_select() { # via completion) merges that single PR directly. ghsq() { if [[ $# -eq 0 ]]; then - local tsv; tsv=$(_gh_pr_multi_select squash --tac) + local tsv; tsv=$(_gh_pr_multi_select squash --layout=reverse) [[ -n "$tsv" ]] && _gh_batch_merge "$tsv" --squash --delete-branch else gh pr merge "${1%%\[*}" --squash --delete-branch @@ -665,7 +667,7 @@ ghsq() { # Interactive PR merge (rebase) — multi-select twin of ghsq. ghrb() { if [[ $# -eq 0 ]]; then - local tsv; tsv=$(_gh_pr_multi_select rebase --tac) + local tsv; tsv=$(_gh_pr_multi_select rebase --layout=reverse) [[ -n "$tsv" ]] && _gh_batch_merge "$tsv" --rebase --delete-branch else gh pr merge "${1%%\[*}" --rebase --delete-branch From 126fb96e95bb8ba5c927488c6c69bccbf774d54a Mon Sep 17 00:00:00 2001 From: Lauri Gates Date: Thu, 9 Jul 2026 13:51:51 +0300 Subject: [PATCH 2/2] feat(zsh): complete `chezmoi edit` with managed source files chezmoi's cobra completion returns nothing for `edit`, so `chezmoi edit ` falls back to whole-filesystem completion. Add a wrapper compdef that offers only files/symlinks tracked in the source dir (via `chezmoi managed`), deferring all other subcommands to the real _chezmoi. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Gq2w8A1vhNjdtG8bH8hqbT --- dot_zshrc.tmpl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 010ec3f5..12d7899c 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -1013,6 +1013,22 @@ autoload -Uz compinit && compinit # Note: Completion definitions must be loaded AFTER compinit to ensure # they are properly registered with the zsh completion system +# Custom completion for `chezmoi edit`: offer managed target files. +# chezmoi's own cobra completion returns nothing for `edit`, so it falls +# back to completing the entire filesystem. Restrict it to files/symlinks +# that actually exist in the source directory (via `chezmoi managed`). +# All other subcommands defer to the real _chezmoi completion. +_chezmoi_edit_managed() { + if [[ ${words[2]} == edit && ${words[CURRENT]} != -* ]]; then + local -a managed + managed=("${(@f)$(command chezmoi managed --path-style=absolute --include=files,symlinks 2>/dev/null)}") + compadd -f -- "${managed[@]}" + return + fi + _chezmoi "$@" +} +compdef _chezmoi_edit_managed chezmoi + # Custom completion for gh PR merge wrappers (ghsq, ghrb) # Lists open PRs with fzf-tab preview of PR details _gh_pr_merge_complete() {