[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Colorized Prompts Problem

On 05/01/2015 12:07 PM, Thomas H. George wrote:
> I entered the following in .bashrc
>    PS1='\033[01;33m\h:\w\$ \033[00m'       
> to colorize the prompt (very handy to find the prompt when a command
> fills the console screen with lines of text)
> The only problem occurs when the next entry is more than one line.  In
> that case the entry wraps around without moving to a new line. Instead
> it overwrites the begining of the current line. The command will still
> work but cannot be revised in the case of a typo.
> For example the prompt alone may be almost a line long, the \w means it
> will contain the full path to the current directory.  The next command
> to be entered is a long one that should wrap to a new line but instead
> begins to overwrite the directory path. You see you made a typo and try
> to move back with the left arrow key and instead the cursor jumps to the
> line above.
> Admittedly this is an infrequent and not a serious problem. Still it is
> annoying when it occurs. Have I made an error in the colorizing prompt?

The bash manpage suggests enclosing the non-printing escape sequences
inside \[ and \]. This is not 100% effective, but it helps.


Reply to: