I'm not sure what-all is not quite right about this code, but it doesn't work for me, even remotely, in xterm.
A couple tips (Bash specifics, but may work for other too):
1) (this is maybe more an FYI than anything, but thought I'd point it out) defining a function doesn't need the "function" keyword, so this is fine:
Code:
redblue () {
code in here...
more code.. blah blah
code code code...
} #end of function
2) I am finding problems with the way you are creating your colors. To create a color, you merely need:
Note that I have not added any [brackets] around that; it will work just fine like this. When I try it your original way, the escaped brackets such as "
\[blah
\]" are being interpreted by the shell as
test commands (test being the
[ symbol), so it acts very strange for me in that regard, and my prompt ends up beginning with the word "test".
So, whether or not the "function" keyword is causing any trouble, I would definitely revisit those escaped brackets in your COLOR variables. I don't see any actual code on that page you linked, so if there's some specific example that would explain where you're coming from, please do post a link to that.
Hope this helps!