Just got started with zsh yesterday but I'm having a lot of trouble getting themes to work. Here is what is showing on my ZSH prompt:
$fg[cyan][$fg[white] keithy $fg[cyan]] [$fg[white]~/Desktop$fg[cyan]] >$reset_color
My ~/.zshrc
source ~/.antigen.zsh
antigen theme jdavis/zsh-files themes/jdavis
Thanks
TL;DR: Corrected .zshrc
is provided at the bottom. You might want to try it first, see it working, then come back to read the explanations.
Inspecting antigen.zsh
and jdavis.zsh-theme
, it looks like you have two problems:
You haven't loaded and executed the colors
function anywhere. Add
autoload -U colors && colors
to your .zshrc
.
PROMPT
is single-quoted and not parsed. You need to use the PROMPT_SUBST
option option to parse the prompt string. Add
setopt promptsubst
to your .zshrc
. What the option does, according to the linked documentation:
If set, parameter expansion , command substitution and arithmetic expansion are performed in prompts. Substitutions within prompts do not affect the command status.
So your .zshrc
should look like
source ~/.antigen.zsh
autoload -U colors && colors
setopt promptsubst
antigen theme jdavis/zsh-files themes/jdavis
It looks like you're trying to use a prompt with color codes from Oh-my-zsh , and perhaps you haven't defined those colors. Try adding the (not sufficient, see comments) redefining the colors in your prompt to default zsh colors . You can play with the colors using the spectrum.zsh
file from Oh-my-zsh (if you don't want to run the entire package) to your source list, orspectrum_ls
function defined in spectrum.zsh
or by changing numeric values in this one-liner (051 is a bright cyan):
zsh -c 'print -P -- "%F{051}Hello, World%f"'
Here is an example of a prompt without the colors defined (top), and a prompt where Oh-my-zsh has been sourced prior to defining PROMPT
(bottom):
See the answer by 4ae1e1 for the individual requirements (Oh-my-zsh automatically sets them).
PATH
is single quoted by default, and is not parsed because of this. Rewrite the var with double quoted string
PATH="$PATH"
source ~/.antigen.zsh
antigen theme jdavis/zsh-files themes/jdavis
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.