Setting up a prompt in bash

I’m setting up programs.bash and in the initExtra I got
initExtra = ‘’
neofetch
h2d() {
echo “ibase=16; $@”|bc
}

  complete -cf sudo

  NC="\[\033[00m\]"
  COLOR1=$(xrdb -query | awk '/prompt.color1/ { print substr($2,2) }')
  qq=';2;'$( h2d ${COLOR1:0:2} )';'$( h2d ${COLOR1:2:2} )';'$( h2d ${COLOR1:4:2} )'m\]'
  COLOR1='\[\033[48'$qq
  COLOR2='\[\033[38'$qq
  export PS1="\n  ${COLOR1}\u${NC}${COLOR2}\h: ${NC}\W ${COLOR2}]${NC} "
'';

When it gets to the export PS1, it says “undefined variable COLOR1” All this “code” has been working forever in my regular .bashrc.

You have to escape the ${.

As you are in an intended string, you have to write ''${ where you want to have ${ in the generated bash script.