Shell – zsh, modularity,multiple .zsh files and oh-the-zsh

debianshellzsh

I use/enjoy zsh and have used oh-my-zsh in couple. While it's all nice and cool, I do get irritated that I have to constantly update the oh-my-zsh script every 15 days/month .

Now I have put zsh as a prompt on another machine. Now the good thing about my oh-my-zsh is that instead of putting everything in .zshrc which when you install .zsh does, it does it in multiple directories with .zsh extension.

While I do not want to go that whole hog, is there a way I can put multiple *.zsh files under say ~/.zsh/ and strive to have a similar working environment.

Can this work or am I missing something ?

Running zsh on debian 64-bit.

Update – There are only two files which can be in my zsh installation –

think-debian% pwd
/home/shirish

think-debian% ls .z
.zcompdump  .zshrc

Any ideas ?

Best Answer

You can set your Zsh dotfiles directory with the ZDOTDIR environment variable; just add it to your ~/.zshenv:

ZDOTDIR="${ZDOTDIR:-$HOME/.zsh}"

Then, source any files in that directory that are named *.zsh from your ~/.zsh/zshrc:

if [[ -d "$ZDOTDIR" ]]; then
  for file in "$ZDOTDIR"/*.zsh; do
    source "$file"
  done
fi

For bonus points, uninstall Oh-My-Zsh and enjoy Zsh as it was intended, a powerful and flexible alternative to Bash, not a bloated ratmangle...

Related Question