1001Ferramentas
🐚 Dev

Minimal .zshrc Generator

Build a lean .zshrc without Oh My Zsh: history, completion, simple prompt with git branch and PATH.

A lean .zshrc, no framework

zsh has been the default shell on macOS since Catalina and gained ground on Linux by shipping what bash only manages with effort: menu completion, typo correction, path expansion mid-word. The common reaction is installing a large framework straight away — and inheriting hundreds of milliseconds of startup time plus a pile of configuration nobody understands.

The page assembles a file that gets to the point, with the options giving the most per line: history shared across sessions and free of duplicates, the completion system switched on, directory navigation without typing cd, and the typo corrections. All of it is native zsh — no plugin and no plugin manager involved.

It pays to know the order the files are read in, because it explains almost every case of a mysteriously missing environment variable. .zshenv is read on every invocation, scripts included. .zprofile only at login. .zshrc in interactive shells, which is where aliases, prompt and completion belong. And .zlogin after zshrc, at login. An environment variable that must apply inside scripts belongs in zshenv, not zshrc.

Frequently asked questions

Do I really need a framework?
No. A framework brings a ready-made theme and a catalogue of plugins, which has value, but charges in startup time and complexity. A thirty-line zshrc covers what most people use. If something specific turns out to be missing later, a lightweight manager can be added without redoing everything.
Why does completion take two lines?
Because compinit initialises the system and has to be called after autoload. The separation exists so you can add completion directories between the two calls. If a warning about insecure directories appears, some folder on the function path has overly broad write permissions.
Can I reuse my .bashrc?
Partly: simple aliases and functions usually work unchanged. What breaks is shell-specific syntax, chiefly arrays, which start at index 1 in zsh and 0 in bash, and unquoted variable expansion, which zsh does not word-split — a difference that has produced bugs in plenty of migrated scripts.

Related Tools