zsh
Startup Source Order
How to maintain good startup scripts. Also known as rc files.
info
TL;DR:
- You don't need
/etc/zshenv
,~/.zprofile
,~/.zlogin
, and~/.zlogout
. - You only need:
~/.zshenv
: For environment variables.~/.zshrc
: For aliases, functions, and auto-completion.
- Call
compinit
ASAP in~/.zshrc
- If you use zsh frameworks (e.g. Oh My Zsh), they might have done this for you.
- That means you should source them ASAP
- If you use zsh frameworks (e.g. Oh My Zsh), they might have done this for you.
compinit
is not the same asbashcompinit
- Zsh is highly compatible with Bash completion scripts.
- If you only have Bash completion scripts, you can use
bashcompinit
instead. - Call
bashcompinit
it right aftercompinit
. - They are independent of each other and can be used together.
Depending on how zsh is invoked, it reads different files. Here is the order:
/etc/zshenv
~/.zshenv
/etc/paths
(only for macOS)~/.zprofile
(only for login shells)/etc/zshrc
(only for macOS)~/.zshrc
(only for interactive shells)~/.zlogin
(only for login shells)- Your shell session
~/.zlogout
(only for login shells)
note
Different systems (even installations) may behave differently. Use zsh -x
to findout what happens on shell startup.
Third party configuration guide
When a CLI tool is installed, they may require some configuration on RC files. For the following reasons:
Type | Where to put |
---|---|
Environment Variables (beside Paths) | ~/.zshenv |
Paths | ~/.zshrc |
Aliases | ~/.zshrc |
Functions | ~/.zshrc |
Auto-completion | ~/.zshrc (After calling compinit ) |
Library
Contains few useful snippets and configs. Independent from each other, mix-and-match as needed.
Frameworks
Manging your configuration files and plugins.
- Antigen: Dead
- Zinit: Very fast, but less maintained, some bugs are left unfixed for a while
- Zim
- zcomet
- Sheldon
- Znap
Prompts
CLI that create dynamic, highly customizable prompts.