oh-my-bash icon indicating copy to clipboard operation
oh-my-bash copied to clipboard

Returning code always 0 in VS Code terminal

Open hgsantana opened this issue 6 months ago • 5 comments

I've been trying to customize a new theme for my needs, and I was trying to use robbyrussell theme as the base for it. When I tried the false command using this theme it didn't apply the brown color to the arrow as it was supposed to do.

So I tried to debug it and placed an "echo $?" just inside the function that generates de prompt:

function _omb_theme_PROMPT_COMMAND() {
  echo "return code $?" # line I added
  if [[ "$?" == 0 ]]; then
    local arrow_color="${_omb_prompt_bold_green}"
  else
    local arrow_color="${_omb_prompt_bold_brown}"
  fi
...

Even typing false on prompt, the return code is always 0:

➜  ~ false
return code 0
➜  ~ true
return code 0

The if statement would always be 0 after I added the new line, since echo returns 0 on success. Nevertheless, the print of $? is always 0 inside the echo command. Something before this function is returning 0 and is not the command executed on prompt.

hgsantana avatar Aug 28 '24 04:08 hgsantana