-1

I have looked at duplicate questions. Nothing has worked.

I use Gitbash, and when using Cygwin, I source the gitbash prompt (/Git/etc/bash.bashrc) to display the same prompt. In Gitbash, the prompt works. In cygwin, the output line wraps. For example:

[ "$python_version" ] && python_version='\[\033[95;38;5;227m\]'"${python_version##* } "

This line causes a wrap (only in cygwin) when appended to PS1. The minttyrc and color settings are exactly the same. Removing the color, which I think is the problem, fixes the wrap. However, I believe everything is escaped correctly, and as it doesn't wrap in gitbash, I don't know what the problem is.

The color here seems to be the issue, as removing it fixes it. But why? What is so different about the terminals? I also wonder if it could be an issue with an early escape, but PyCharm's shellcheck says it's all fine.

Wrapping example:

Cygwin: ⬢14.7.0p/new 3.8.3 (venv) ❯

GitBash (ideal output): ~/Desktop/new 3.8.3 ⬢14.7.0 (venv) ❯

It only occurs within the prompt (PS1 variable, aka PROMPT_COMMAND); not when actually typing out commands in the terminal.

  • Maybe an eol issue? (https://stackoverflow.com/a/39091313/6309) – VonC Aug 11 '20 at 05:46
  • I'm sorry, I don't completely understand. How could I potentially fix it then? I've also heard there are just bugs within cygwin itself, and that several people have advised to just not use it. – Barrett Ruth Aug 11 '20 at 05:57
  • Not sure, considering I don't use Cygwin. I usually find git bash enough. What do you need from Cygwin in your case? – VonC Aug 11 '20 at 05:59
  • Certain tools, such as g++ and using ssh (tell me if I'm wrong about this) REQUIRE cygwin. I've learned I can ssh in using bash with `ssh -t user@host "bash -l"`; however, this always ends up using the PS1 set in cygwin, and I don't think there's a solution to that; so I've ended up just copying my PS1 file for gitbash, and now I have the line wrapping error when I ssh in. – Barrett Ruth Aug 11 '20 at 06:04
  • Those are valid reason (using a POSIX compliant shell) to use Cygwin indeed. By line wrapping, do you mean like https://superuser.com/q/283236/141? – VonC Aug 11 '20 at 06:06
  • @ByNoMeans : I don#t understand your question. The line you stated, just assigns a value to the variable `python_version`. Nothing is printed here. Hence, I don't see where a line wrapping could occur, if you don't print anything. – user1934428 Aug 11 '20 at 06:09
  • "This line causes a wrap (only in cygwin) when appended to PS1." Hope that clears things up. – Barrett Ruth Aug 11 '20 at 06:10
  • @VonC The wrapping only actually occurs in lines like the one given within PS1, everything is fine when typing out. – Barrett Ruth Aug 11 '20 at 06:12
  • please provide the exact `output` .Where is wrapping ? – matzeri Aug 11 '20 at 06:25
  • @matzeri Example provided. – Barrett Ruth Aug 11 '20 at 06:28

1 Answers1

0

Answer: Cygwin is trash (excuse the exaggeration). It has so many utilities but many have encountered bugs like this, and it is really a shame. I uninstalled it, removed its variables from PATH, and with C:\Program Files\Git\bin added to such, I could now ssh in using ssh -t user@host bin "bash -l". This gave me a correct prompt, in ssh or not, with no wrapping; I was able to install other utilities, such as g++, using MinGW. I hope Cygwin gets things sorted out soon, as I debugged in every single way; changed no code, uninstalled it, and then had a successful output.

  • That would have been my first answer too. As I commented, I usually manage without Cygwin. – VonC Aug 11 '20 at 07:53
  • Mixing utility is your problem not Cygwin one. Cygwin defaults do not modify the PATH, so you did by yourself – matzeri Aug 11 '20 at 12:33
  • I don't know why you're even saying that; at any point in time if I opened up Mintty it would've line wrapped, which is the problem, regardless of the path; Mintty ALWAYS line wrapped, sshed in or not. The point it that the code itself is fine, and Cygwin still had errors. Yes, I shouldn't've altered the path how I did, but Cygwin still had errors outside of my control. – Barrett Ruth Aug 11 '20 at 18:43