Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do you need to source .zshrc for every new shell in iTerm?

I've used Iterm2 with zsh everyday for the past 3 years, but I got a new computer and had to set it up again. The problem is that when I run ~/.zshrc it works fine, but I have to do it on every new terminal window I open. Not a good experience.

I noticed that I don't have any bashrc, bash_profile, or profile (dot)files on my new machine.

Here's the code in ~/.zshrc:

export ZSH=/Users/healy/.oh-my-zsh
plugins=(
  git
)
ZSH_THEME="agnoster"
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
DEFAULT_USER=healy

Again, it works perfectly (and as expected), but only after I run the source command, and that shouldn't be the case.

enter image description here

like image 243
Trevor Avatar asked Jun 04 '18 23:06

Trevor


People also ask

What does source Zshrc do?

source evaluates or runs the content of a file. For example, if you source ~/. zshrc you apply the content of the file to the currently running Zsh process. You can source and valid Zsh code.

What is .zshrc Mac?

zshrc file is used to configure the zsh shell, you'll need to manually create one in your home directory for zsh to access. There's also a system-level zshrc file, but that is less commonly modified by users. Do note that if you install Oh My Zsh, a . zshrc file will be created automatically for you.

How do I save Zshrc changes?

Enter the command ” touch ~/. zshrc“. A new file will be created in the directory. Open and edit the file with the text editor of your choice and save the changes.

What is the difference between zsh and Bash?

Bash lacks syntax highlighting and auto-correction features. Zsh has syntax highlighting and auto-correction features. In bash keybinding is done using '. inputrc' and 'bind builtin'.


Video Answer


2 Answers

Make sure your export/source are added after the plugins in your zshrc, as stated in this post: oh-my-zsh config file not loading

like image 172
kenji Avatar answered Oct 03 '22 15:10

kenji


On starting a new shell just run the command source ~/.zshrc by configuring in the

Preferences -> Profiles -> Select Default Profile(default profile will be starred) -> General -> Command -> Select Login Shell -> Send text at start:

Enter the value source ~/.zshrc.

You may add source ~/.zshrc; clear in case you need to clear the screen contents after executing the command.

like image 8
Vignesh Raja Avatar answered Oct 03 '22 17:10

Vignesh Raja