Add Syntax Highlighting in Zsh Shell

To add Syntax Highlighting in Zsh Shell, follow the below steps,

  1. Open the Terminal on your Mac/Linux.
  2. Make sure you have brew installed.
    % brew --version
    Homebrew 4.0.19
  3. Now you will need to install package zsh-syntax-highlighting using HomeBrew.
    % brew install zsh-syntax-highlighting
  4. Make sure to edit the .zshrc file and add the following.
    source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  5. Run the below command to activate syntax highlighting.
    % source ~/.zshrc

Now when you will try to run commands with options on your Zsh shell you will see the text getting syntax highlighted (blue and red).

Syntax Highlighting in ZSH Shell

If you face any problems in these steps, do let me know in the comments, I will try to assist.

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!