sorin-ionescu / prezto

The configuration framework for Zsh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question/FR] Add Dracula ZSH Theme

NovaViper opened this issue · comments

I'm triyng to add the Dracula ZSH theme to my install but there's no instructions on how to actually add themes that are hosted in github. Is it possible to add the theme to my setup?

Sadly, this isn't really Prezto's fault, but more that the Dracula Zsh theme doesn't adhere to the promptinit standard, which comes with Zsh. It only provides an Oh-My-Zsh zsh-theme. You can read more about the proper way to set up a Zsh prompt here.

However, it is possible to shoehorn this theme into Prezto. You will can add this snippet to your .zshrc prior to sourcing Prezto's init.zsh, or you can just run it once from an interactive Zsh session:

# .zshrc
# get dracula theme
ZPREZTODIR=${ZPREZTODIR:-${ZDOTDIR:-~}/.zprezto}
if [[ ! -d $ZPREZTODIR/contrib/dracula ]]; then
  git clone https://github.com/dracula/zsh $ZPREZTODIR/contrib/dracula
  echo 'setopt prompt_subst' >! $ZPREZTODIR/contrib/dracula/init.zsh
  mkdir -p $ZPREZTODIR/contrib/dracula/functions
  echo '. $ZPREZTODIR/contrib/dracula/dracula.zsh-theme' >! $ZPREZTODIR/contrib/dracula/functions/prompt_dracula_setup
fi

Then, in your .zpreztorc, add 'dracula' to the module list, but do it before loading the 'prompt' module. You'll also need to set your zstyle ':prezto:module:prompt' value to 'dracula':

# .zpreztorc

# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  ... \
  'dracula' \
  'prompt' \
  ...

# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'dracula'

By doing this, I got it to work. It might be worth working with the Dracula theme folks to make a PR that adds a proper prompt_dracula_setup function, but for now, this seems to work.

Vote to close this issue.

After answering this question, I was inspired to make a prompt contrib that has some other popular prompts like starship, lean, and all the OMZ themes, with support for 3rd party OMZ themes like Dracula too. Feel free to grab it here: https://github.com/mattmc3/prezto-prompt-contrib

The recommended suggestion for new modules is to use a custom contrib-module and keep the core of prezto tiny.