Splitting up a .zshrc file
I've being using ZSH as my default shell for probably about 6 or 7 years now. I've been carting around a
.zshrc config file for about that long. I store it in Dropbox and symlink it to the home directory on the machines I use. This has generally worked quite well, but recently I've run into a particular issue.
In the past I've always shared a computer for work and personal use, but I'm in the process of setting up a new computer for personal use only so I can have a stricter separation between work and personal life. When it came to syncing my
.zshrc file however, I noticed that there were certain things in the file such as AWS credentials for work that I didn't really want to have on my personal machine. The solution was pretty straightforward, however. I split my config file into three files:
zshrc_shared. The first two files would contain any config commands specific to those contexts and then one line of the special source (pun intended 😜):
This line imports the contents of
zshrc_shared, so I can share config commands between both environments. Very handy!