Frage

I've been trying to create a fancy oh-my-zsh theme, but unfortunately I've hit an annoying roadblock.

eval gray='$FG[245]'
yellow='226'
ret=$?
# error check
[[ $ret -ne 0 ]] && yellow='100'#THIS LINE NOT FUNCTIONING
#prompt
PROMPT='$gray%~ $(git_prompt_info)${FG[$yellow]}%(!. ⚡ .»)%{$reset_color%}'
RPROMPT='$gray%n:%m%{$reset_color%}$?'

This is what I have so far, line six doesn't work though, I've tried single brackets, I've tried adding running it as sh and not as zsh, I've also tried swapping $ret for $? and even moving the whole thing to a full if-then setup, so far, none of it has worked. Did I screw up the syntax somehow, or will it just not work due to the environment or implementation?
Note:
This is oh-my-zsh so this config file is to modify the command prompt of the terminal, $? being the return value of the last run command.

War es hilfreich?

Lösung

yellow='226'

This always succeeds and $? is 0 afterwards.

Andere Tipps

Roger is right, the failing line is useless. However, I believe your primary issue is that you are using single quotes, and the string substitution is not happening.

$ a=foo

$ echo "$a"
foo

$ echo '$a'
$a

So, use double quotes! Single quotes are for literals.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top