I have defined in one file which I source from .bashrc
, color constants.. like these..
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
When I try to use them in my $PS1 variable I am getting strange results, in that everything looks fine till I press CTRL-R
for recursive history search when few characters on the begining scramble, so I am able for example to delete them pressing CTRL-D
in shell behind that -> pointer :
I am using $'..'
notation, to be able to insert unicode chars..
PS1=$'\xE2\x99\x94 [\\t][\u]->'
so now, what is the proper way of inserting variable like $txtblu
from above, into PS1
line..?
EDIT:
so line like this one:
PS1=$'\n\W\xe2\x98\x85 '$txtpur'\n\n[\t]'$txtrst'[\u]->'
makes rendering of symbols and colors ok, but when I press Ctrl+R, type few chars, and then Ctrl+B few(2 of them I think) characters appear on the beginning of resulting command search which are not belonging to that history line, and I am able to delete them.
echo $BASH_VERSION
)? You probably need to put\[
before and\]
after to tell the shell the color escape sequences don't move the cursor position.