I feel like organizing ~/.zshrc file is the digital equivalent of organizing your drawer. After a while, you realized you gathered some weird pins, coins, and utensils you never use. Or in the case of ~/.zshrc, you find weird aliases, exporting PATH all over the place, API tokens (don’t do this), etc. They are also not the most urgent things to clean, but once in a while it feels good to take everything out and put them back in. ๐Ÿ˜…

Thankfully, there are people who actually take dotfiles like ~/.zshrc more seriously. I think a few years ago I realized there were even tools to manage dotfiles, like chezmoi . Perhaps one day I will have some dotfiles I’m proud to share, but that will not be today.

Instead, today I spent some time doing some refactoring:

~/.config/zsh/
|-- path.zsh # PATH additions
|-- env.zsh ## Environment variables
|-- aliases.zsh # Aliases
|-- secrets.zsh # tokens

And the main ~/.zshrc file is now just a bunch of sources (with a few other things for Oh-My-Zsh and conda init).

for f in ~/.config/zsh/{path,env,aliases,secrets}.zsh(N); do
  source "$f"
done

I have also seriously considered using the Fish shell. I’ll try it out without doing a permanent switch - hopefully I’ll report back in a future TIL.