Development

How to reload zsh configuration

Advertisements

I have been using zsh for quite some time now and learned something new while setting up some commands today. I was trying to reload zsh configuration after making some changes. I knew it was a source command but did not remember the complete one. So I googled and found that there is a new way to do it now too.

The old way

The source command has been the go to way of reloading your zsh config. Simply type in:

source ~/.zshrc
Bash

And it works without any errors. But I recently learned of a newer way.

A new command

As is the nature of things in programming land, new things always come to the stage and omz added a new alias to make reloading zshrc configuration more rememberable. The new command to reload zsh configuration is:

omz reload
Bash

I also found out another interesting thing. I assumed it was an alias to the source command under the hood but turns out that it is an alias for

exec zsh
Bash

The exec command is different than source because it completely reloads the zsh process. This means that the exec command removes any env variables that were set before in the configuration which can be a better default than having a rogue state after doing a reload.

So if you’re an omz user, you can use the reload command or for other zsh users, you can use the exec command which is probably easier to remember too. And those are the 2 ways to reload your zshrc configuration.

Saransh Kataria

Born in Delhi, India, Saransh Kataria is the brain behind Wisdom Geek. Currently, Saransh is a software developer at a reputed firm in Austin, and he likes playing with new technologies to explore different possibilities. He holds an engineering degree in Computer Science. He also shares his passion for sharing knowledge as the community lead at Facebook Developer Circle Delhi, NCR which is a developer community in Delhi, India.

Share
Published by
Saransh Kataria

Recent Posts

Remapping keyboard keys to avoid Carpal Tunnel

I am terrible at optimizing my keyboard layout for anything. But off lately, my little…

1 week ago

Fixing cookies are blocked for a website with shields down on Brave

I recently switched completely to the Brave browser and have set ad blocking to aggressive…

4 months ago

Generating a QR code using Node.js

I was preparing a slide deck for a hackathon and decided to put in a…

5 months ago

How to clear the global npx cache

I have been using npx a lot lately, especially whenever I want to use a…

6 months ago

Copy/Pasting output from the terminal

Manually copy-pasting the output of a terminal command with a mouse/trackpad feels tedious. It is…

6 months ago

How To Get The Hash of A File In Node.js

While working on a project, I wanted to do an integrity check of a file…

7 months ago
Advertisements