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

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…

2 weeks ago

Native popover API in HTML

Popovers have been a problem that was typically solved by using a third-party solution. But…

3 weeks ago

Node.js 20.6 adds built-in support for .env files

Node.js 20.6 added built-in support for the .env file. This is an excellent addition to the platform…

4 weeks ago

Object destructuring in TypeScript

Object destructuring is a powerful ES 6 feature that can help developers write cleaner code.…

1 month ago

Improve git clone performance in a CI pipeline

Have you felt particularly annoyed by the time it takes to clone a large repository,…

2 months ago

Fix: Hydration failed because the initial UI does not match what was rendered on the server

Within a React or Next.js app, if you encounter the error "Hydration failed because the…

2 months ago
Advertisements