Colorized output breaks linewrapping with readline

前端 未结 3 669
迷失自我
迷失自我 2020-12-16 03:52

I\'m working with colorizing some output using readline in Ruby, but I am not having any luck getting line wrapping to work properly. For example:

\"\\e[01;         


        
3条回答
  •  天涯浪人
    2020-12-16 04:33

    This problem is not ruby-specific - it occurs in bash too. If you put in a bash shell

    PS1="\e[01;32mThis prompt is green and bold\e[00m > "
    

    you will see the same result as above. But if you put in

    PS1="\[\e[01;32m\]This prompt is green and bold\[\e[00m\] > "
    

    you will get the result you wanted.

提交回复
热议问题