aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-14 11:05:31 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-14 11:05:31 +0100
commitb60042404a8aeab81b81380b401d638fb20a1b0e (patch)
tree0fa64efaa623c5203d16bc1ba2b745b335c598af /dot_config
parent41926591c513a42a30992a641e5d2875395c1c86 (diff)
downloaddotfiles-b60042404a8aeab81b81380b401d638fb20a1b0e.tar.gz
dotfiles-b60042404a8aeab81b81380b401d638fb20a1b0e.tar.bz2
dotfiles-b60042404a8aeab81b81380b401d638fb20a1b0e.zip
fix(zsh): guard compdef on target command being installed
On minimal hosts (remote-dev VM, fresh container) several of the `compdef alias=target` lines fail at login with messages like: compdef: unknown command or service: just compdef: unknown command or service: systemctl compdef: unknown command or service: lsd — because zsh has no `_just`/`_systemctl`/`_lsd` completion function loaded when the binary isn't on the system. Wrap each call in a small helper that checks $commands[<target>] first so absent tools just silently skip their alias completion instead of spamming the prompt.
Diffstat (limited to 'dot_config')
-rw-r--r--dot_config/zsh/dot_zshrc16
1 files changed, 11 insertions, 5 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc
index fda6853..97bb6ac 100644
--- a/dot_config/zsh/dot_zshrc
+++ b/dot_config/zsh/dot_zshrc
@@ -344,11 +344,17 @@ alias gdbr='gdb -ex start --args'
alias copilot='gh copilot --autopilot --enable-all-github-mcp-tools --yolo --resume'
# ── Alias completions ─────────────────────────────────────────────────────────
-compdef g=git
-compdef j=just
-compdef n=nvim ndiff=nvim nd=nvim nview=nvim nv=nvim
-compdef sys=systemctl ssys=systemctl sysu=systemctl
-compdef l=lsd la=lsd lt=lsd
+# Guard each compdef on the target command being installed; otherwise zsh
+# prints `compdef: unknown command or service: foo` on every login (e.g. on
+# minimal remote-dev VMs where `just`/`lsd` aren't part of the system).
+# Usage: _dot_compdef <target-cmd> <alias>=<target> [<alias>=<target>...]
+_dot_compdef() { (( $+commands[$1] )) && compdef "${@:2}" }
+_dot_compdef git g=git
+_dot_compdef just j=just
+_dot_compdef nvim n=nvim ndiff=nvim nd=nvim nview=nvim nv=nvim
+_dot_compdef systemctl sys=systemctl ssys=systemctl sysu=systemctl
+_dot_compdef lsd l=lsd la=lsd lt=lsd
+unfunction _dot_compdef
# ── GPG agent ─────────────────────────────────────────────────────────────────
# Set GPG_TTY to this shell's actual TTY (not the login console) and tell