I want to have a colored prompt in bash. Usually, I do this like this, for example:
read -p $'\033[1;32m hello world?' helloWorld
This works fine, but no variables are expanded in the prompt string. Now I want color and expanded variables, but this does not work:
read -p $'\033[1;32m hello $thisVariableIsNotExpanded ?' helloWorld
I tried just using echo -e
instead of read -p
, but this adds a linebreak which I do not want.
So, how can I have colors and variable expansion in a read prompt?