Thursday, September 4, 2025
HomeGuest BlogsConfigure Zsh syntax highlighting on Linux / macOS

Configure Zsh syntax highlighting on Linux / macOS

Zsh syntax highlighting enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This will help you in reviewing commands before running them, particularly in catching syntax errors.

We’ll use scriptzsh-syntax-highlighting to configure Zsh syntax highlighting on our Linux system or a macOS with Zsh installed. If you’re new to zsh, check my guide on How to Install and Configure Zsh on Linux

Once you have installed and set zsh as your default shell, clone zsh-syntax-highlightingfrom Github and source it on your ~/.zshrc

mkdir ~/.scripts
cd ~/.scripts
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

The file that you need to source on  your ~.zshrc is ~/.scripts/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Edit your .zshrc file

vim ~/.zshrc

Add the following line at the end of the file

source ~/.scripts/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh

Source it manually to start using syntax highlighting

source ~/.zshrc

To confirm that Zsh syntax highlighting is working, try to write a for loop on your current shell

for i in a b c; do
  echo "Printing value  
  echo $i
done

See below screenshot

zsh syntax highlighting min

Syntax highlighting is done by pluggable highlighter scripts. See the documentation on highlighters for details and configuration settings. Have a happy Zsh syntax highlighting sessions.

RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6632 POSTS0 COMMENTS
Nicole Veronica
11800 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11859 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS