Why ZShellCheck?
Zsh is a powerful, feature-rich shell, but its complexity can lead to subtle bugs, performance issues, and hard-to-maintain scripts. While bash has ShellCheck, Zsh has lacked a dedicated, modern static analysis tool that understands its unique syntax and semantics. ZShellCheck fills this gap, providing a friendly "sensei" to guide you toward writing better Zsh code.
Show, Don't Tell
(Animated GIF of ZShellCheck in action will be here)
Gallery of Wisdom (Features)
Here are a few examples of how ZShellCheck helps you improve your Zsh code.
❌ Before (The "Confused Grasshopper")
# Example 1: Incorrect array access
my_array=(one two three)
echo $my_array[1] # This doesn't do what you think!
# Example 2: Using legacy command substitution
files=`ls *.zsh`
# Example 3: Unsafe use of '['
if [ $ZSH_VERSION > 5.0 ]; then
echo "Modern Zsh"
fi
✅ After (The "Enlightened Master")
# Example 1: Correct array access
my_array=(one two three)
echo $my_array[1] # ZShellCheck: [ZC1001] Use ${my_array[1]} for array element access.
echo ${my_array[1]}
# Example 2: Using modern command substitution
files=$(ls *.zsh) # ZShellCheck: [ZC1002] Use $(...) instead of backticks for command substitution.
# Example 3: Safe and powerful '[['
if [[ $ZSH_VERSION > 5.0 ]]; then # ZShellCheck: [ZC1003] Prefer [[...]] over [...] for modern Zsh tests.
echo "Modern Zsh"
fi
Installation
(Coming soon)
Homebrew (macOS)
brew install afadesigns/zshellcheck/zshellcheck
Go
go install github.com/afadesigns/zshellcheck/cmd/zshellcheck@latest
From Binary
Download the latest release from the Releases page.
The Dojo (Usage)
zshellcheck your_script.zsh
Learn the Katas (Rules)
ZShellCheck uses a system of "Katas" (rules) to teach you better Zsh. Each Kata has a unique ID and a detailed explanation.
➡️ See the full list of Katas in our Wiki