oh-my-zsh config file not loading
Asked Answered
O

6

49

I am trying to get ZSH config working correctly on Mac OSX. I installed it using curl: curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh. Then I modified my zshrc file to fit my needs. It works only after I run source ~/.zshrc. But then if I come back and open a new tab or new terminal I have to do source ~/.zshrc to get the config settings to work again. Has anybody ran into this issue? I believe there is a way to make it so I don't have to do source ~/.zshrc with every new tab.

Overthrow answered 28/3, 2013 at 12:58 Comment(5)
Have you tried logging out and back in?Spaceport
Yes I have restarted the machine. I just got a new Mac and have this issue now. I also run Linux Mint and have the same issue. All of it works after running source ~/.zshrc so if I can get that config to load on login it would fix it.Overthrow
Restarting should not be necessary, but often login and just opening a new terminal can be different. I am running out of ideas, but the one thing you could try is see if the env. variable ZDOTDIR is set (e.g. in /etc/zshenv), if that is set it determines from where .zshrc is read, and only if not set it takes ~/.zshrc . Also see zsh manpage (It has been a while since I used zsh)Spaceport
zsh on Mac OS X should work without requiring you to source ~/.zshrc so I'll ask a possibly stupid question: have you set your shell to zsh (default is bash)?Horan
Yes my default shell is zsh it loads the zsh prompt when I open the terminal or a new tab.Overthrow
O
42

I figured this out. It was due to my config file. The part of the zsh config that wasn't loading needed to be moved down after the plugins load. After moving that it all worked as expected.

Overthrow answered 8/4, 2013 at 14:42 Comment(5)
could you give some more details? I'm having the same probvlemVerde
What is your specific issue? I had to move some of my custom codings below the plugins= line source $ZSH/oh-my-zsh.sh bindkey '^R' history-incremental-search-backward autoload -U edit-command-line zle -N edit-command-line bindkey -M vicmd v edit-command-line That fixed it for meOverthrow
Cool. I've finally found the problem, somehow plugins and loading oh-my-zsh became swapped. The correct order for reference: plugins=(osx git ) then source $ZSH/oh-my-zsh.sh.Verde
More generally, any oh-my-zsh config needs to be loaded before sourcing $ZSH/oh-my-zsh.shMenides
@AndrewHundt your comment was the exact solution in my case. It just feels unnatural for the plugins to be called first and then OMZSH to be sourced!Genovese
V
32

If you have themes like Powerlevel9k installed for your zsh shell then source the oh-my-zsh config file after the theme variable assignments in your .zshrc file like shown below.

Eg:

........
........
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=('status' 'load' 'ram_joined' 'time')

# source oh-my-zsh config
source $ZSH/oh-my-zsh.sh
Vasileior answered 27/5, 2017 at 13:43 Comment(3)
I tried all the above solutions but I was still facing the problem. This Solution worked for me. Thanks.Isador
This was what I needed as well!Kantos
This is perfect. Saved me. Thank you!Emblematize
C
8

Not the ideal solution but solves the issue:

Terminal -> Preferences -> Profiles -> Shells -> Startup

Check the box that says "Run command" and in the input box run

source ~/.zsh/.zshrc

This will be executed when you open a new terminal window / tab.

Centralia answered 2/12, 2019 at 19:7 Comment(1)
changing the Shells Open with option is a better Idea. - 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.Georgettegeorgi
S
7

My final solution was to go to Terminal --> Preferences --> General --> Shells open with --> Command (complete path), and set it to /bin/zsh (or your path to zsh), and then set both New windows/tabs open with to "Same profile". It works fine for me.

My initial attempt was to go to Terminal --> Preferences --> Profiles, and in my default profile's "shell" tab's Startup section, I set it to run command "source ~/.zshrc". This also solved the problem of /.zshrc not loading, but it seemed tedious to see that command show on every terminal tab/window.

Sailboat answered 19/11, 2016 at 12:52 Comment(0)
N
1

I had a similar problem. I found that I had long ago changed my Terminal preferences to run tcsh instead of the default login shell. Took me forever to figure this out!

Nette answered 31/8, 2013 at 16:15 Comment(0)
M
1

On mac zsh it is loading ~/.zsh_profile on shell start. So just create one like this will do.

echo "source ~/.zshrc" > .zsh_profile

Or just put your .zshrc content into .zsh_profile. Whatever works for you.

Merited answered 17/6, 2023 at 17:1 Comment(1)
I would just create a symlink to the file so when you edit one file the other is updated too (it points to the first one).. no double-edit is required in that case :-) ln -s ~/.zshrc ~/.zsh_profileEurhythmics

© 2022 - 2024 — McMap. All rights reserved.