That was one problem. But there was also a problem with \[ and \]. But
I solved it with writing a routine to find out the values of the
original prompt.
I now use:
set colourStart "\001\033\["
set colourEnd "m\002"
set colour1 [format "%s1;31%s" ${colourStart} ${colourEnd}]
set colour2 [format "%s1;32%s" ${colourStart} ${colourEnd}]
set colour3 [format "%s1;37%s" ${colourStart} ${colourEnd}]
and because the root user is a special case, I also have:
set user $::tcl_platform(user)
if {${user} eq "root"} {
set temp ${colour1}
set colour1 ${colour2}
set colour2 ${temp}
}
and I create the prompt with:
format "%s%s %s\[%s %s@%s:%s\]\n$ %s" \
${colour1} \
tclsh${::tcl_version} \
${colour2} \
${dateTime} \
${user} \
${host} \
${currentDir} \
${colour3}
And maybe I should write a proc to create the colours. Something like:
[getColour redLight]
is a bit more clear as:
[format "%s1;31%s" ${colourStart} ${colourEnd}]