Split the zshrc file into multiple files
March 31, 2021 ‐ 1 min read
When you get a long way with configuring ZSH your ~/.zshrc can get a bit bulky, filled with aliases and more.
At some point you might prefer to split up your .zshrc file into multiple files. You can easily do so by creating a config directory with files that you source from your .zshrc.
I chose the location "$HOME/.config/zsh/config.d/" to store separated config files, here I have the following files for example: aliases.zsh, history.zsh, fzf.zsh.
From my .zshrc I loop over all the files in "$HOME/.config/zsh/config.d/ with a .zsh file extension and source them.
# ~/.zshrc
# Load seperated config files
for conf in "$HOME/.config/zsh/config.d/"*.zsh; do
source "${conf}"
done
unset conf