My .zshrc became is too long to maintain it easily. I’ve decided to take the idea behind apache configuration in Debian and to split the .zshrc parts into easily maintainable subscripts. I have no idea if ZSH supports this in some vim-like form of .zsh/plugins, so I did it manually.
The first step is to create the following directories
and to make a backup of old .zshrc like this
Open the ~/.zshrc file with your favourite editor, and copy the following into it (replacing the old code):
Now, open .zshrc.backup file we created earlier and split it into modules which you’ll save into ~/bin/zsh-modules-available. You can split it up any way you want. For example, one of the modules could be the following:
The last step is to choose which modules you want enabled, and to specify the order of execution by prefixing the names with a number from 00 to 99.
Go to the ~/bin/zsh-modules-enabled and do the following for the modules you want to enable:
That’s all folks
So, you have a easily maintainable ZSH module system - it is easy to add a new one, to delete an old one, easy to switch them off or on… You could even create functions such as zsh_module_enable/disbable, but I’m too lazy for that. (aka, if you do, please post them in the comments section and I’ll add them to the post.