Common Corner Case where Prompt Background bleeds into Input Field
Prompt that is longer than terminal size and wraps around, draws the background after prompt incorrectly after prompt reaches bottom of terminal.
Environment:
- Iterm2 Build 3.0.10
- MacOSX El Capitan 10.11.16
- Python 2.7.12
- Bash 4.4.0
I have been able to reproduce on several mac laptops. How to reproduce:
- Enter a super long directory that wraps around
- Keep pressing enter on keyboard until prompt reaches bottom of terminal.
Can someone try and reproduce, and let me know i'm not crazy.
I'm also able to reproduce using Mac Terminal Version 2.7.

Interestingly, I didn't have this issue when I initially tried to reproduce it. But normally I use the "flat" display mode so I don't have the unicode arrows in my prompt. I should test whether this is a contributing factor.
doesn't seem to be the unicode characters. I was not experiencing this when I originally attempted to reproduce because using the newline segment prevents the issue.
After more testing it appears to be related to the use of colors. I stripped out the code that adds any colors and the issue disappears. Still need to dig further into this.
I am inclined to think this is a bug with bash or some other underlying system. I have been testing with a very simple PS1 with colors:
PS1='\[\e[48;05;10m\] \w \[\e[0m\]'
Which results in the same error. That prompt just sets the background color, prints the current directory, then resets the background color. I am getting the same bleeding with it.
Ok, I believe I found a solution:
export PS1='\[\033[48;05;10m\] \w \[\033[0m\]\[\033[0K'
Will need to test a bit more.
Woah interesting. I am curious how you found that. I tried searching around for this problem but didn't come up with anything.
Here we go ( see the Clear Line bullet point ):
Hmm , I think the search was for "ansi color vt100 color codes lines wrap" that came up with that search result.
This appears to fix it:
diff --git a/powerline_shell/__init__.py b/powerline_shell/__init__.py
index 68eb227..603b425 100644
--- a/powerline_shell/__init__.py
+++ b/powerline_shell/__init__.py
@@ -90,7 +90,7 @@ class Powerline(object):
self.cwd = get_valid_cwd()
mode = config.get("mode", "patched")
self.color_template = self.color_templates[args.shell]
- self.reset = self.color_template % '[0m'
+ self.reset = self.color_template % '[0m\]\[\e[0K'
self.lock = Powerline.symbols[mode]['lock']
self.network = Powerline.symbols[mode]['network']
self.separator = Powerline.symbols[mode]['separator']
Looks about right based on what you've provide so far. This will need some extensive testing, including against other shells.
I have the same issue, after applying the suggested patch, things seem to be working correctly. I am running bash 4.4.12 on Ubuntu 17.10.
The proposed fix broke things on Mac (#389 )
As a local fix in one's bashrc - we can add in the _update_ps1 function (from the README).
PS1=${PS1//\[0m/[0m\\]\\[\\e[0K}
Essentially it is doing the thing from bytebeast's comment as a postfix (note the extra \ for escaping \ )
This change works for me!