How to Set Up Oh My Zsh with Autosuggestions and Syntax Highlighting

Oh My Zsh terminal setup with autosuggestions and syntax highlighting

I spend most of my day in the terminal — as a full stack developer jumping between git, docker, package managers, and remote servers, the default bash experience always felt like it was slowing me down. Then I switched to Oh My Zsh, added a few plugins, and the difference was immediate.

This is the exact setup I install on every new machine. It takes about five minutes and gives you autosuggestions from your command history, real-time syntax highlighting so you can spot typos before hitting enter, and smarter tab completion. If you work in the terminal regularly, this will save you a lot of keystrokes.

What Are Zsh and Oh My Zsh?

Zsh (Z shell) is a Unix shell that improves on bash with better tab completion, globbing, and scripting features. It's been the default shell on macOS since Catalina, and it's available on every Linux distribution.

Oh My Zsh is a framework that sits on top of Zsh. It manages your shell configuration, makes it easy to install plugins and themes, and gives you sensible defaults out of the box. Think of it as the package manager for your terminal experience.

Prerequisites

You'll need curl and git installed. On Ubuntu/Debian, run:

sudo apt install curl git

If you're on a different distribution, use your package manager instead — dnf on Fedora, pacman on Arch, etc.

Step 1: Install Zsh

Install Zsh and set it as your default shell:

sudo apt install zsh
sudo chsh -s $(which zsh) $(whoami)

The chsh command changes your default login shell. You'll need to log out and back in (or restart your terminal) for this to take effect. You can verify it worked by running echo $SHELL — it should show /usr/bin/zsh.

Step 2: Install Oh My Zsh

Run the official installer — it clones the Oh My Zsh repository into ~/.oh-my-zsh and sets up a default .zshrc configuration file:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

After installation, your terminal will already look different — Oh My Zsh comes with the robbyrussell theme by default, which shows your current git branch in the prompt. But the real power comes from the plugins.

Step 3: Install Plugins

These three plugins are what make the terminal genuinely more productive. Each one needs to be cloned into Oh My Zsh's custom plugins directory.

zsh-autosuggestions

This plugin suggests commands as you type based on your command history. The suggestions appear as ghost text — press the right arrow key to accept, or keep typing to ignore. Once you get used to it, you stop typing most commands past the first few characters.

git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

zsh-syntax-highlighting

This highlights your commands in real time as you type. Valid commands turn green, invalid ones turn red, and strings and arguments get their own colors. It catches typos before you hit enter, which is surprisingly useful.

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-autocomplete

This gives you real-time tab completion with a dropdown menu of suggestions. It works for commands, file paths, git branches, and more — no need to press Tab first, the suggestions appear as you type.

git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autocomplete

Step 4: Configure Your .zshrc

Open your ~/.zshrc file and find the plugins line. Replace it with:

plugins=(git ssh-agent zsh-autosuggestions zsh-autocomplete zsh-syntax-highlighting)

A few things to note about the order: zsh-syntax-highlighting must be the last plugin in the list — the plugin requires this to work correctly. The other plugins can be in any order.

git and ssh-agent are built-in Oh My Zsh plugins. The git plugin gives you useful aliases like gst for git status and gco for git checkout. The ssh-agent plugin automatically starts your SSH agent and loads your keys on shell startup.

Step 5: Apply Changes

Reload your shell configuration to pick up the new plugins:

source ~/.zshrc

You should immediately see autosuggestions appearing as ghost text and command highlighting as you type. If something doesn't look right, try closing and reopening your terminal.

Bonus: Accept Suggestions with Double-Tab

By default, you accept autosuggestions with the right arrow key. I prefer using double-Tab since my fingers are already there. Add this line to the bottom of your ~/.zshrc:

bindkey '^I^I' autosuggest-accept

^I is the terminal code for the Tab key, so ^I^I means pressing Tab twice. Single Tab still triggers normal completion — this only fires when you tap Tab quickly twice in a row.

That's It

This setup has been my daily driver for a while now, and every time I use a machine without it, I notice the difference immediately. The autosuggestions alone save me from retyping long commands, and the syntax highlighting catches more mistakes than I'd like to admit.

If you want to take it further, look into Powerlevel10k as a theme — it's fast, highly customizable, and shows useful context like git status, Node version, and execution time right in your prompt. But that's a topic for another post.