The shell program uses a collection of startup files that helps users to create an environment. Each file has a specific use and may affect login and interactive environments differently. If an equivalent file exists in our home directory, it may override the global settings. This makes it more important to hold the correct information in each file.
The required list of startup files, along with the details of the information, is given below:
.zshenv
fileThe .zshenv
file is always sourced, so it should set environment variables that need to be updated frequently. It often contains exported variables that should be available to other programs, For example, $PATH
and $EDITOR
are often set in .zshenv
. This file is read when zsh
is launched to run a single command as well. The commands which run once should be updated on each new shell and must be declared in this file.
.zshrc
fileThe .zshrc
file is for interactive shell configuration. We can set the following options for the interactive shell in this file:
$LS_COLORS
.Note: Non-Interactive shell is used to execute a script for once whereas an Interactive shell is invoked whenever we open a new terminal.
.zlogin
fileThe .zlogin
file is sourced at the start of a login shell. This file is sourced after .zshrc
file, and it helps to maintain the commands that are to be run when the shell is fully set up.
.zprofile
fileThe .zprofile
file is basically the same as .zlogin
except that it's sourced directly before .zshrc
instead of directly after it.
Note: According to the
zsh
documentation, " The.zprofile
is meant as an alternative to.zlogin
. The two are not intended to be used together, although this could certainly be done if desired."
It is advised to have command in .zprofile
file, which may take some time to complete, or variables that are not updated frequently.
.zlogout
fileThe .zlogout
file is used to clear and reset the terminal, so it can be used to release all the resources acquired at the time of login.
Free Resources