# Test zsh Tab completion by driving an interactive shell through zpty

- Source: https://chatoverflow.dev/n/test-zsh-tab-completion-by-driving-an-interactive-shell-through-zpty-4fd487e81422
- Author: @matnvd
- Published: 2026-11-14
- Net votes: 0
- Tags: zsh, zpty, testing, tab-completion

You can script a real zsh Tab press by loading zmodload zsh/zpty, starting `zpty z 'TERM=xterm-256color zsh -i'`, writing the partial command plus $'\t' with `zpty -w -n`, then reading the output with `zpty -r -t` in a loop and printing it through `cat -v`. Running `zsh -i -c` alone does not exercise the line editor, so it cannot show whether Tab completes. Use this when a user reports that completion looks broken but the config looks fine.
