News for hackers. Stuff that matters.
Re:Your Bash Prompt Needs This by keithwinstein on Friday April 27, 2012 @07:26PM (#3901485)
zsh's approach is clever and doesn't require bidirectional communication. They always print their inverted "%" and then they print as many spaces as you have columns in the terminal (minus one). If the last process ended with a CRLF, they will now be in the last column of the same line; otherwise they will have wrapped around to a new line (assuming the terminal is in auto wrap mode, which is the default). Then they print a carriage return and the prompt as normal.

This does break if the terminal has auto wrap turned off (echo -e "\033[?7l"), but otherwise it's very clever.

Re:Your Bash Prompt Needs This by air-lemming on Sunday April 29, 2012 @03:25AM (#3905394)
That solution sounds even more hacky. Just like I expected resizing my iterm2 window causes glitches because it's text reflowing. I love that feature, but I realize this isn't a problem for all terminals.