Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$? -ne 0 Not Working

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.


1 Answers

yellow='226'

This always succeeds and $? is 0 afterwards.

like image 94
Roger Pate Avatar answered May 20 '26 09:05

Roger Pate