ZSH with Powerlevel10k didn't work on terminal startup

Viewed 5943

I'm using Fedora 31 and had installed ZSH (Oh-my-zsh) with PowerLevel10k. When I open gnome-terminal I got ZSH as the default shell, as I expected. But Powerlevel10k is just loaded when I type: source ~/.zshrc

This is my zshrc file content:

plugins=(git)
source $ZSH/oh-my-zsh.sh
ZSH_THEME=powerlevel10k/powerlevel10k

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
"~/.zshrc" 110L, 4104C  

Another important thing is that every time I type source ~/.zshrc, I got the following error, but everything works fine with Powerlevel10k:

[ERROR]: When using instant prompt, Powerlevel10k must be loaded before the first prompt.
1 Answers

You need to move ZSH_THEME=powerlevel10k/powerlevel10k above source $ZSH/oh-my-zsh.sh. ZSH_THEME tells Oh My Zsh which theme should be loaded, so it must be set before you source Oh My Zsh.

Related