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

7

39

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

Telmatelo answered 4/6, 2018 at 23:8 Comment(2)
You probably didn't change your default shell : apple.stackexchange.com/questions/191780/…Kabuki
@Kabuki If that were the case, sourcing a Zsh configuration file would almost certainly cause an error. (Although I'm assuming that zsh-autosuggestions.zsh contains something that bash couldn't interpret properly.)Dated
W
25

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

Woodson answered 26/8, 2018 at 0:26 Comment(1)
I'm pretty sure this was the solution I came to as well.Telmatelo
M
21

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.

Mercurous answered 6/6, 2018 at 7:26 Comment(0)
P
6

I had the same issue and changing the Shells Open with option fixed this for me.

To get here:

  • Open Preferences for Terminal
  • Select the General Tab
  • Change Sells open with from Default login shell to Command (complete path) with the /bin/zsh in the input box.

Screeshot:

Screenshot

Pelagic answered 15/6, 2020 at 17:9 Comment(0)
D
1

In my case, oh-my-zsh is not loaded because the line was comment out.

# IT'S WRONG! NEED TO UNCOMMENT
# export ZSH=/Users/$(whoami)/.oh-my-zsh

Though this question is not due to the same "comment out" obviously, I came to a conclusion that, if you need to source ~/.zshrc every time opening a shell instance, there should be some issue with your .zshrc, and check oh-my-zsh and antigen(maybe) work fine.

Deductive answered 8/5, 2019 at 16:25 Comment(0)
M
1

On 11.2.1 with Terminal 2.11, assuming you have already created .zshrc in your home directory, launch Terminal and select Terminal >> Preferences >> Profiles >> Shell

Under "Startup" check "Run command:" and input source ~/.zshrc

Mcelrath answered 16/2, 2021 at 21:3 Comment(0)
B
1

In my case I'm using the default Mac terminal. I'm in the OSX Sonoma which has zsh as the default shell. To fix the autocomplete I:

  1. CMD+,
  2. Click Profile at the top menu
  3. Click the Shell submenu
  4. Check the box [X] Run command: source ~/.zshrc
  5. Quick Terminal and relaunch

Probably the Mac default zsh is not loading .oh-my-zsh? Is there a way to tell the default zsh to use .oh-my-zsh when terminal opens? Is my solution the way of doing this?

Thoughts?

Bewray answered 16/11, 2023 at 15:54 Comment(0)
I
-1

for me,It works like this. Profiles 》Open Profiles 》Select “Edit Profiles” 》Profiles 》General and put "source ~/.zsh" into Send text at start textfield.

Index answered 17/4, 2019 at 9:19 Comment(1)
changing the Shells Open with option is a better Idea. you can find the steps in the above answers. cheersLeticialetisha

© 2022 - 2024 — McMap. All rights reserved.