Post

How to Store zsh and VSCode Configuration in GitHub

Back up your zsh and VSCode configuration to GitHub so you can sync settings across machines.

How to Store zsh and VSCode Configuration in GitHub

Maintaining a consistent development environment is crucial for productivity, especially when switching between machines or collaborating with others. By storing your zsh and VSCode configurations in GitHub, you can easily back them up, track changes, and sync them across devices.

In this guide, I’ll show you how to store your current zsh and VSCode configurations in GitHub, ensuring you always have access to your customized settings.

Why Store Configurations in GitHub?

  • Consistency: Quickly set up your development environment on new devices.
  • Version Control: Track changes to your configurations and roll back if needed.
  • Backup: Prevent accidental loss of your carefully tuned settings.
  • Collaboration: Share your configuration with colleagues or the community.

Step 1: Set Up a GitHub Repository

The first step is to create a GitHub repository where you’ll store your configuration files.

  1. Log in to GitHub and create a new repository, for example, dotfiles. You can make the repository private if you don’t want to share your configurations publicly.
  2. Clone the newly created repository to your local machine:

    1
    2
    
    git clone https://github.com/your-username/dotfiles.git
    cd dotfiles
    

Step 2: Backup and Store Your zsh Configuration

Your zsh configuration is stored in a hidden file called .zshrc located in your home directory.

  1. Navigate to the cloned repository and copy your current .zshrc file:

    1
    
    cp ~/.zshrc ./  # Copies the .zshrc to the repository folder
    
  2. Stage and commit the .zshrc file to Git:

    1
    2
    
    git add .zshrc
    git commit -m "Add zsh configuration"
    
  3. Push the changes to your GitHub repository:

    1
    
    git push origin main
    

This will back up your zsh configuration to GitHub, where you can retrieve it at any time.

Step 3: Backup and Store Your VSCode Configuration

VSCode stores its settings in a settings.json file, which is located in the User folder.

  1. On macOS/Linux, the settings file is located here:

    1
    
    ~/Library/Application Support/Code/User/settings.json
    
  2. Copy the settings.json file to your cloned GitHub repository:

    1
    
    cp ~/Library/Application Support/Code/User/settings.json ./  # For macOS/Linux
    
  3. Stage and commit the settings.json file:

    1
    2
    
    git add settings.json
    git commit -m "Add VSCode settings"
    
  4. Push the settings to GitHub:

    1
    
    git push origin main
    

Step 4: Retrieve and Restore Configurations

If you switch to a new machine or want to restore your configuration files, simply clone your repository and copy the configuration files back to their respective locations.

For zsh:

1
cp .zshrc ~/.zshrc  # Restore .zshrc to the home directory

For VSCode:

1
cp settings.json ~/Library/Application Support/Code/User/settings.json  # Restore VSCode settings on macOS/Linux

Conclusion

By storing your zsh and VSCode configurations in GitHub, you ensure that your development environment is backed up, versioned, and easily accessible across devices. This simple process of backing up and restoring configurations can significantly improve productivity, whether you’re setting up a new machine or collaborating with others.

☕ Support My Work

If you found this post helpful and want to support more content like this, you can buy me a coffee!

Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏

This post is licensed under CC BY 4.0 by the author.