Skip to content

Commit c523f8a

Browse files
committed
ZSH: Add completions directory, fix fpath order, use complete-word
Add ~/.config/zsh/completions/ as a chezmoi-managed fpath directory for static completion files. Move chezmoi completion there and keep only the alias binding in the sourced file. Fix linuxbrew fpath additions to happen before compinit. Switch Tab from menu-complete to complete-word to avoid unexpected expansion of globs and variables.
1 parent dae5662 commit c523f8a

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ completion "zsh" }}

home/dot_config/zsh/exact_private_zsh.d/private_050_completion.zsh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
# ZSH completion system {{{
22
# ---------------------------------------------------------------------------
33

4-
# Initialize the completion system
4+
# Custom completions directory managed by chezmoi
5+
fpath=(~/.config/zsh/completions $fpath)
6+
7+
# Load all completions from linuxbrew
8+
if [[ -d /home/linuxbrew/.linuxbrew/share/zsh/site-functions ]]; then
9+
fpath=(/home/linuxbrew/.linuxbrew/share/zsh/site-functions $fpath)
10+
fi
11+
if [[ -d ~/.linuxbrew/share/zsh/site-functions ]]; then
12+
fpath=(~/.linuxbrew/share/zsh/site-functions $fpath)
13+
fi
14+
15+
# Initialize the completion system (must be after fpath additions)
516
autoload -Uz compinit && compinit
617

718
# Git completion for aliases (must be after compinit)
@@ -42,14 +53,3 @@ function __complete_new()
4253
compdef __complete_new new
4354
# ---------------------------------------------------------------------------
4455
# }}}
45-
# Load all completions from linuxbrew {{{
46-
# ---------------------------------------------------------------------------
47-
if [[ -d /home/linuxbrew/.linuxbrew/share/zsh/site-functions ]]; then
48-
fpath=(/home/linuxbrew/.linuxbrew/share/zsh/site-functions $fpath)
49-
fi
50-
if [[ -d ~/.linuxbrew/share/zsh/site-functions ]]; then
51-
fpath=(~/.linuxbrew/share/zsh/site-functions $fpath)
52-
fi
53-
54-
# ---------------------------------------------------------------------------
55-
# }}}

home/dot_config/zsh/exact_private_zsh.d/private_050_misc_config.zsh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,10 @@ setopt NO_NOMATCH
264264
# Use emacs key bindings (same as bash default)
265265
bindkey -e
266266

267-
# Cycle through available completions with Tab
268-
bindkey '^I' menu-complete
267+
# Use complete-word instead of the default expand-or-complete. This skips
268+
# expansion (globs, aliases, variables) and jumps straight to completion,
269+
# avoiding unexpected substitutions like $PWD expanding into a full path.
270+
bindkey '^I' complete-word
269271

270272
# Cycle in reverse with Shift-Tab
271273
bindkey '^[[Z' reverse-menu-complete
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Chezmoi completion is loaded from ~/.config/zsh/completions/_chezmoi
2+
3+
alias erchoso=chezmoi
4+
compdef _chezmoi erchoso

home/dot_config/zsh/exact_private_zsh.d/private_100_complete_chezmoi.zsh.tmpl

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)