Why does this shell-script dim my bash colors? My ~/.bash_profile contains this:

function rgb {
    # https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
    let "sum = 16 + 36*$1 + 6*$2 + $3"
    # echo "\[\e[${sum}m\]"
    tput setaf ${sum}
}

  BOLD=$(tput bold)
   DIM=$(tput dim)
 RESET=$(tput sgr0)

BRIGHT=$(rgb 5 5 5)
  BLUE=$(rgb 1 1 5)
YELLOW=$(rgb 4 4 1)

PS1="\n"
PS1+="\[${DIM}\]"
PS1+="\u@"
PS1+="\[${BRIGHT}\]"
PS1+="\h "
PS1+="\[${BLUE}\]"
PS1+="\w "
PS1+="\[${YELLOW}\]"
PS1+="\$(git_branch)"
PS1+="\n"
PS1+="\[${BRIGHT}\]"
PS1+="&gt; "
PS1+="\[${BOLD}\]"

echo ${BOLD}


If I just execute the above as a separate foo.sh file, it leaves my bash window dim:



(Edit: Screenshot fail, . foo.sh behaves the same)

Even upgrading my bash version thru Homebrew fails to shift this.

What's going on?
Because your function told it to do so?

See wikipedia tput page, IBM tput tutorial  &amp; man tput  

Google bash prompt &amp; tput and you get quite a few suggestions on how to set up your prompt.  

Comment out the function you posted in your ~/.bash_profile.
Start a new terminal. Things should be normal again.