You probably don't need Oh My Zsh

5 min read Original article ↗

Oh My Zsh is still getting recommended a lot. The main problem with Oh My Zsh is that it adds a lot of unnecessary bloat that affects shell startup time.

Since OMZ is written in shell scripts, every time you open a new terminal tab, it has to interpret all those scripts. Most likely, you don't need OMZ at all.

Here are the timings from the default setup with a few plugins (git, zsh-autosuggestions, zsh-autocomplete) that are usually recommended:

  ~ /usr/bin/time -f "%e seconds" zsh -i -c exit
0.38 seconds

And that's only for prompt and a new shell instance, without actually measuring the git plugin and virtual env plugins (which are often used for Python). Creating a new tab takes some time for your terminal, too. It feels like a whole second to me when opening a new tab in a folder with a git repository.

My workflows involve opening and closing up to hundreds of terminal or tmux tabs a day. I do everything from the terminal. Just imagine that opening a new tab in a text editor would take half a second every time.

Once in a while, it also checks for updates, which can take up to a few seconds when you open a new tab.

I see no reason in frequent updates for my shell configuration. Especially, when a lot of third-party plugins are getting updates too. Why would you want you shell to fetch updates?

My advice is to start simple and only add what you really need.

Minimal Zsh configuration

Here is the minimal Zsh configuration that works well as a starting point:

export HISTSIZE=1000000000
export SAVEHIST=$HISTSIZE
setopt EXTENDED_HISTORY
setopt autocd
autoload -U compinit; compinit

It's an already pretty good setup with completions!

Some details about this configuration:

  • HISTSIZE and SAVEHIST set the size of your history.
  • EXTENDED_HISTORY adds timestamps to your history entries.
  • autocd allows you to change directories without typing cd.
  • compinit initializes the Zsh completion system.

Prompt customization

You also want to customize your prompt. For prompts, I'm using starship which is a fast and minimal prompt packed into a single binary.

The very old way of doing this in Oh My Zsh was to use plugins and custom themes. With starship, it's very simple and easy now. It replaces git, virtual environment and language specific plugins.

Here is my config for starship:

[aws]
disabled = true

[package]
disabled = true

[gcloud]
disabled = true

[azure]
disabled = true


[nodejs]
disabled = true

[character]
success_symbol = '[➜](bold green)'

[cmd_duration]
min_time = 500
format = 'underwent [$duration](bold yellow)'

[directory]
truncation_length = 255
truncate_to_repo = false
use_logical_path = false

Because cloud services are available globally, I've disabled them. I don't want them to be displayed on every prompt, since this adds visual noise.

Here is how my prompt looks like now:

This project uses both Python and Rust, they are highlighted in the prompt. When you run a command, it also shows how long it took to execute.

To enable it, add the following line to your .zshrc:

eval "$(starship init zsh)"

History search

A lot of people use zsh-autosuggestions plugin for history search. I find it distracting, because it shows all suggestions as you type.

Instead, I prefer using fzf binded to Ctrl+R for searching history. It gives an interactive fuzzy search.

To enable it, add the following lines to your .zshrc:

Final startup time

After these changes, the startup should look as follows:

 /usr/bin/time -f "%e seconds" zsh -i -c exit
0.07 seconds

Miscellaneous tips

For Vim users, I also suggest enabling Vim mode in Zsh. It makes editing commands much faster.

set -o vi
# Fix for backspace in vi mode
bindkey -v '^?' backward-delete-char

It works the same way as in Vim. By default, zle (the library that reads the shell input) uses Emacs keybindings.

Conclusion

After switching from OMZ a year ago, it only took me a few days to get used to the new workflow. If you still missing some of the plugins, you can always load them manually.

Update:

Some people wonder why I open so many tabs. I use tmux and a terminal-based editor (helix). In tmux, I have popups for lazygit and yazi file manager. Every time I need to check git history or browse files, I just open them. They open on top of the current session as an overlay. You can view them as windows in IDEs.

I also use temporary splits to quickly run the code/tests and see the output. They count as separate shell sessions. I want to see code and output side by side, but I don't need it all the time.


If you have any questions, feel free to ask them via e-mail displayed in the footer.
All articles on this website are written by a human without LLM assistance.