Knowing your zsh configuration

2025-08-05

If you are like me, changed to zsh and listen to most people around you without reading the docs. Hear me out. Just using a .zshrc will be enough in most cases. But will introduce pain points on the long run.

TL;DR

.zprofile behaves the same to .profile/.bash_profile. Use it if their are env variables that need to be set/exported for every logged in shell. Not just spawned terminal windows.

For example:

export GDK_DPI_SCALE=2 # scale them GDK apps on high dpi monitors
export ELECTRON_OZONE_PLATFORM_HINT=auto # tell electron apps to remember their zoom level. Obsidian etc.
export EDITOR=nvim # set your default editor

Instead of tediously managing .desktop files for every application to ,for example, scale them properly.

How zsh configuration files get sourced

Source order:

  1. .zshenv is loaded for all types of shell sessions
  2. .zprofile if the shell is a login shell. Same behavior as .profile
  3. .zshrc if the shell is interactive
  4. .zlogin on login shells

You will notice that both .zprofile and .zlogin are run on login shells. The only real difference is the source order.

Lets look at how these configuration files are meant to be used.

Here is the Official Documentation for the files handling.

My .zprofile

export EDITOR=nvim
export MANPAGER='nvim +Man!'

# QT high dpi behavior
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export QT_SCALE_FACTOR=2

# GDK high dpi behavior
export GDK_DPI_SCALE=2
export GDK_SCALE=2

export ELECTRON_OZONE_PLATFORM_HINT=auto