oh-my-zsh config file not loading

邮差的信 提交于 2019-12-18 04:30:10

问题


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.


回答1:


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.




回答2:


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



回答3:


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.




回答4:


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!




回答5:


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.



来源:https://stackoverflow.com/questions/15682456/oh-my-zsh-config-file-not-loading

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!