From b60042404a8aeab81b81380b401d638fb20a1b0e Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 14 May 2026 11:05:31 +0100 Subject: fix(zsh): guard compdef on target command being installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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[] first so absent tools just silently skip their alias completion instead of spamming the prompt. --- dot_config/zsh/dot_zshrc | 16 +++++++++++----- 1 file 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 = [=...] +_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 -- cgit v1.3.1