Problem
I have a ps1 script and it's working fine (I'm using \[$(tput setaf x)\]). But when I use a printf with colors I have 2 scenarios:
line overlapping
printf $(tput setaf 2)HI!$(tput sgr0)
Which prints HI! in green but breaks the wrapping
printing \[\]
printf \[$(tput setaf 2)\]HI!\[$(tput sgr0)\]
Which prints \[\]HI!\[\]
Note
I also tried to use echo without success