Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 949 forks source link

Add modifications in different file #1404

Closed redeemefy closed 4 years ago

redeemefy commented 4 years ago

Hi all,

I would like to know if it is possible to add custom setting in a different file instead of .zshrc. I do all my custom zsh related things in files in ~/.oh-my-zsh/custom/custom.zsh. I created ~/.oh-my-zsh/custom/pl9k.zsh file and add the configuration bellow, but doesn't work. I had to add that code to the ~/.zshrc to make it work. It is a way I can move that code to a custom file or has to be in ~/.zshrc for now.

Is there plans to make this work?

 19 # Load Nerd Fonts with Powerlevel9k theme for ZSH
 18 POWERLEVEL9K_MODE='nerdfont-complete'
 17 source /Users/gdiaz/.oh-my-zsh/custom/themes/powerlevel9k/powerlevel9k.zsh-theme
 16
 15 # Customise the Powerlevel9k prompts
 14 POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
 13   dir
 12   custom_javascript
 11   vcs
 10   newline
  9   status
  8 )
  7 POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
  6 POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
  5
  4 # Create a custom JavaScript prompt section
  3 POWERLEVEL9K_CUSTOM_JAVASCRIPT="echo -n '\ue781' JavaScript"
  2 POWERLEVEL9K_CUSTOM_JAVASCRIPT_FOREGROUND="black"
  1 POWERLEVEL9K_CUSTOM_JAVASCRIPT_BACKGROUND="yellow"

Thanks!

Syphdias commented 4 years ago

You can just source the file you created in your ~/.zshrc. So in your case: source ~/.oh-my-zsh/custom/pl9k.zsh.

Make sure to set (or source) every variable before sourcing the theme file itself since not every variable is picked up otherwise.

Since you are using omz you can also set ZSH_THEME=powerlevel9k/powerlevel9k instead of source /Users/gdiaz/.oh-my-zsh/custom/themes/powerlevel9k/powerlevel9k.zsh-theme. In this case make sure you source your variables before sourcing oh-my-zsh.sh.