cirho / powerline-rust

powerline-shell written in Rust
MIT License
50 stars 25 forks source link

Output looks odd in macOS bash #9

Closed trepidacious closed 4 years ago

trepidacious commented 4 years ago

If I run powerline directly, I get reasonable output, but running from .bash_profile using the recommended approach gives mangled output. You can see both in this screenshot: Screen Shot 2019-11-08 at 14 39 04

It looks a little like it's returning to the start of line somewhere through the prompt. The behaviour is the same in VS Code terminal and normal macOS terminal.

I've tried some other powerline implementations (e.g. powerline-go) using the same configuration in .bash_profile and they work fine, but I prefer Rust :)

cirho commented 4 years ago

It will have to wait till Monday, because I don't own anything with MacOS, but be sure that if it's a problem with powerline-rust the issue will be resolved.

trepidacious commented 4 years ago

I've just checked and I get the same thing in WSL Ubuntu 18.04. I wonder if something has changed in rust nightly? I'm on rustc 1.40.0-nightly (1423bec54 2019-11-05).

It seems like what's happening is that some number of characters into the line, the cursor returns to the start of the line, losing any custom colors, and continues printing over the top of the previous output. This only happens if the line is long enough, and is being used as a prompt; just running the executable normally produces perfect output.

trepidacious commented 4 years ago

Removing the fg/bg colors from printing produces correct output, so I guess the color codes are confusing the terminal:

if let Some(next) = iter.peek() {
  write!(f, "{}{}", seg.val, seg.sep)?;
} else {
  write!(f, "{}{}", seg.val, seg.sep)?;
}

image

Just in case it's relevant, I'm trying both the VS Code integrated terminal and the normal WSL terminal, and they do the same thing.

trepidacious commented 4 years ago

Ah it turns out it was my fault! I didn't realise it was defaulting to bare-shell, it works fine now I've reinstalled with:

cargo install --no-default-features --features "bash-shell libgit"

Might it be worth adding this to the Bash section of the readme? I assumed that because there was a note for zsh but none for bash, bash must be the default? Might also be worth giving the command line options for people new to Rust?

cirho commented 4 years ago

bash-shell used to default, but I changed it temporary for personal use and forgot to undo. I have already fixed it.

Lack of command line options is design choice. You don't change your prompt every day, so why should powerline always parse it.

cirho commented 4 years ago

Regardless of everything, thanks for investigating and pointing it out.

trepidacious commented 4 years ago

No problem, thanks for the project :)

On the command line options point I agree that not having options for the powerline executable itself makes sense - I meant the options for cargo to build with the features for bash (or zsh); it took me a little while to work out how to do this, so it might be handy for people who are new to rust.

cirho commented 4 years ago

Detailed installation instructions have been added to readme, so there is no need for this issue to remain opened any longer.