GuideOctober 21, 20256 min read

The Complete Guide to Syncing Your Zsh Configuration

Your shell is the most personal tool in your development environment. Here's how to sync every part of your Zsh setup across machines without losing a single alias.

What Makes Up a Zsh Configuration

Most developers think of their shell config as a single file: .zshrc. In reality, a complete Zsh setup spans multiple files, each loaded at different stages of shell initialization:

  • ~/.zshenv — loaded for every shell (including scripts), sets environment variables
  • ~/.zprofile — loaded for login shells, sets PATH and session-level variables
  • ~/.zshrc — loaded for interactive shells, your aliases, plugins, prompt, and keybindings
  • ~/.aliases — a common convention for separating alias definitions

If you only sync .zshrc, you will lose environment variables set in .zshenv, PATH entries from .zprofile, and any aliases broken out into a separate file. ConfigSync tracks all four by default.

Adding Zsh to ConfigSync

A single command detects and tracks your entire Zsh configuration:

Add the Zsh module
configsync add module zsh

This automatically discovers .zshrc, .zprofile, .zshenv, and .aliases if they exist. All four files are captured in a single snapshot whenever you push.

Push your shell config
configsync push -m "zsh config with aliases"

On a new machine, pulling restores every file to the correct location:

Pull on a new machine
configsync pull

Handling Platform Differences with Templates

If you work across macOS and Linux, your PATH and tool locations differ. Homebrew on macOS installs to /opt/homebrew/bin, while Linux package managers use /usr/local/bin. ConfigSync templates handle this cleanly:

~/.zprofile with platform template
{{#if platform == "darwin"}} # macOS Homebrew export PATH="/opt/homebrew/bin:$PATH" export PATH="/opt/homebrew/opt/python@3.12/bin:$PATH" {{else}} # Linux export PATH="/usr/local/bin:$PATH" export PATH="$HOME/.local/bin:$PATH" {{/if}} # Common across all platforms export EDITOR="nvim" export LANG="en_US.UTF-8"

When ConfigSync restores this file, it evaluates the template for the current platform. Your macOS machine gets Homebrew paths. Your Linux server gets the correct alternatives. One config file, zero manual editing.

Syncing Oh My Zsh

Oh My Zsh stores custom plugins and themes in ~/.oh-my-zsh/custom/. The built-in plugins ship with Oh My Zsh and do not need syncing, but any custom plugins or themes you have added do.

Add custom Oh My Zsh content
# Track custom plugins and themes configsync add file ~/.oh-my-zsh/custom/plugins/my-aliases/my-aliases.plugin.zsh configsync add file ~/.oh-my-zsh/custom/themes/my-theme.zsh-theme # Or track the entire custom directory configsync add directory ~/.oh-my-zsh/custom/

On the new machine, install Oh My Zsh first (it takes ten seconds), then pull your ConfigSync snapshot. Your custom plugins and themes land in the right directory automatically.

Tip: You do not need to sync the entire ~/.oh-my-zsh/directory. The framework itself should be installed fresh. Only sync your custom additions in the custom/ folder.

Syncing Starship Prompt

If you use Starship instead of (or alongside) Oh My Zsh themes, its configuration lives in a single file: ~/.config/starship.toml. ConfigSync has a dedicated module for it:

Add Starship
configsync add module starship

Starship is cross-shell, so the same starship.toml works whether you are using Zsh on macOS, Bash on a Linux server, or Fish on your personal laptop. This makes it an ideal candidate for syncing: one config file produces the same prompt everywhere.

Auto-Sourcing After Pull

After pulling new shell configuration, your current terminal session still has the old config loaded. You can set up a post-pull hook to source the new config automatically:

Post-pull hook in configsync.yaml
modules: zsh: post_pull: - "source ~/.zshrc"

This runs source ~/.zshrc after every pull that touches Zsh files. Your current session picks up the new aliases and functions immediately without opening a new terminal window.

The Full Zsh Sync Setup

Here is the complete setup for syncing your entire Zsh environment:

Complete setup
# Core Zsh config (4 files) configsync add module zsh # Oh My Zsh custom plugins and themes configsync add directory ~/.oh-my-zsh/custom/ # Starship prompt configsync add module starship # Push everything configsync push -m "complete zsh setup" # On a new machine: # 1. Install Oh My Zsh # 2. Install Starship # 3. configsync pull --install

From a blank machine to your fully customized shell in under two minutes. Every alias, every function, every prompt tweak, every plugin, all restored exactly as you left them.

Ready to try ConfigSync?

Sync your entire dev environment across machines in minutes. Free forever for up to 3 devices.