Conemu: 24-bit Colors with Win10 Bash (WSL)

Created on 14 Nov 2016  ·  23Comments  ·  Source: Maximus5/ConEmu

Versions

ConEmu build: 161024 x64
OS version: Windows 10 x64
Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): Windows 10 Bash (WSL)

Problem description

24-bit Colors in WSL. I've done exactly as instructed here. When I try to start the task, it gives me the typical cmd error of conemu-cyg-32.exe does not exist. The command for the task is conemu-cyg-32.exe ./wslbridge.exe -t "-new_console:C:%LOCALAPPDATA%\lxss\bash.ico" "-new_console:D:C:\test" -new_console:np. All of the files from C:\test are from the wsl-con.cmd provided. When I run wsl-con.bat it launches the task in a new tab perfect and running 256colors2.pl and the colors look fine. Why does the bat file work fine, but I get the conemu-cyg-32.exe does not exist when I run the task?

Steps to reproduce

  1. Follow Guide on ConEmu.github.io
  2. Try starting Console with given example command (modified to work on my setup)
  3. Get error about conemu-cyg-32.exe not existing

Actual results

Error about conemu-cyg-32.exe not existing

Expected results

Open WSL Bash with 24-bit Colors

Most helpful comment

I just encountered that problem and made a workaround that seems to be working

Add to ~/.bash_aliases

# "clear" command that "supports" 24bit colors
alias clear='clear; echo -ne "\e[32766H\e[$((LINES - 1))A"'

Add to ~/.bashrc

# Clear the screen, scroll beyond limits, and set cursor at the first visible line
clear; echo -ne "\e[32766H\e[$((LINES - 1))A"

# Bind Ctrl+L to alias
bind -x '"\C-l": clear'

Now bash echoes the prompt beyond limits and both clear and Ctrl+l work properly.


P.S. That thing also enables support of bold and italic fonts! I thought they're completely dead on windows but it suddenly turned out they're not (normal console on top, console after \033[9999H on bottom):

Bold and italic fonts

P.S.S. Airline (aka powerline) for Vim can display bold font but it doesn't look like it scrolls screen 9999 lines down. How's did they do that?

Airline

All 23 comments

Follow "guide" (you have not said "what guide") step-by-step to get proper results.

The one I linked in the problem description: https://conemu.github.io/en/BashOnWindows.html

And the page tells where you can get connector: https://conemu.github.io/en/CygwinMsysConnector.html

I've already looked at that, but in your guide that I linked, you said "Well, you may run wsl-con.cmd which would set up wslbridge for you.". I did this. You also said to use the command conemu-cyg-32.exe ./wslbridge.exe -t "-new_console:C:%LOCALAPPDATA%\lxss\bash.ico" "-new_console:D:C:\MSYS\WSL" -new_console:np to set up your new task to run Win10 Bash with 24 colors. I changed the C:\MSYS\WSL to my own folder, currently I'm using C:\test as my wslbridge folder which contains all the files that were downloaded with wsl-con.cmd.

When I run that new task with the command you gave which in my case is conemu-cyg-32.exe ./wslbridge.exe -t "-new_console:C:%LOCALAPPDATA%\lxss\bash.ico" "-new_console:D:C:\test" -new_console:np I get this as a result.

For further information, this is what my C:\test looks like.

What if you add -dir C:\test to the Task parameters? Any changes?
Show the contents of the C:\test folder?

That does seem to make the task boot properly, but there's no 24 color support as seen here:
screenshot_34

Please don't use external picture hostings. Github can embed them nicely...

Was unaware, fixed it.

I see.

Try to replace conemu-cyg-32.exe ./wslbridge.exe -t with wsl-con.cmd -run. Specify full path to cmd file if required.

That works, though I have to specify the full path using the task parameters. If I take out the task parameters and do C:\test\wsl-con.cmd -run I get the error of conemu-cyg-32.exe not existing again. Why does the cmd file work but not conemu-cyg-32.exe ./wslbridge.exe -t? As well as this just starts the color script every time. Would I have to edit the cmd and take out that part or do you have a better idea?

That's due to limitation.
https://conemu.github.io/en/AnsiEscapeCodes.html#xterm_256_color_processing_requirements
You have to scroll the console to the bottom of the buffer. The section :do_run in the cmd file is doing that. So you may either copy these three lines top your own cmd file and run it in Task or do the same echo in your bash profile and run connector from the task.

I might do the first one you mentioned, though could you explain what you meant by the second option?

Adding the line echo -e '\e[9999H' into the .bashrc might work.

Seems to have worked... I have one more problem, when starting it, every thing (like my PS1) starts at the bottom until I hit ctrl + l. What can I put in my .bashrc to make it clear or ctrl + l at the start?

EDIT: I see where this is coming from as you said I'd have to scroll to the bottom of the buffer. As I understand now why it does that, is there any way of making it clear screen after scrolling to the bottom?

Haven't you read my messages? That is limitation. After ctrl-l you'll lose 24bit colors.

How do you get it to execute a command in the task? Right now my task is %WslBaseDir%\wsl-con.cmd -run "-new_console:C:%LOCALAPPDATA%\lxss\bash.ico" "-new_console:np" & "ssh user@server" , but the last & "ssh user@server" part does not execute

I quickly came up with solution. it's not pretty or well thought out at all. but im glad i learned a fundamental i didnt know b4

wsl-con.cmd original

line 88 conemu-cyg-32.exe ./wslbridge.exe -t ./wsl-boot.sh 

wsl-con.cmd modified

line 88 conemu-cyg-32.exe ./wslbridge.exe -t ./wsl-boot.sh %~2

wsl-boot.sh original

line 5 bash -l -i 

wsl-boot.sh modified

bash -l -i -c "ssh $1"

conemu task original

%WslBaseDir%\wsl-con.cmd -run  "-new_console:C:c:\path\to\icon\icon.ico" "-new_console:np:t:tabName"' 

conemu task modified

%WslBaseDir%\wsl-con.cmd -run  "-new_console:C:c:\path\to\icon\icon.ico"  "user@server" "-new_console:np:t:tabName"

-run = first argument
"user@server" = second argument

I just encountered that problem and made a workaround that seems to be working

Add to ~/.bash_aliases

# "clear" command that "supports" 24bit colors
alias clear='clear; echo -ne "\e[32766H\e[$((LINES - 1))A"'

Add to ~/.bashrc

# Clear the screen, scroll beyond limits, and set cursor at the first visible line
clear; echo -ne "\e[32766H\e[$((LINES - 1))A"

# Bind Ctrl+L to alias
bind -x '"\C-l": clear'

Now bash echoes the prompt beyond limits and both clear and Ctrl+l work properly.


P.S. That thing also enables support of bold and italic fonts! I thought they're completely dead on windows but it suddenly turned out they're not (normal console on top, console after \033[9999H on bottom):

Bold and italic fonts

P.S.S. Airline (aka powerline) for Vim can display bold font but it doesn't look like it scrolls screen 9999 lines down. How's did they do that?

Airline

Note 1. ConEmu buffer may be greater than 9999 lines (current maximum is 32766). So some users have to change these numbers.
Note 2. Vim switches buffer to alternative mode which does not have scrolling. So all works from the box in Vim.

Oh, now I see what alternative mode means, thanks!

ConEmu buffer may be greater than 9999 lines

I'm aware of that limitation and originally tried to use \e[32999H but any value bigger than 32768 behaves like 0.
But I just made some more tests and it turned out that “working area” starts not after last buffer line, but after last buffer line minus screen height. I.e. set window height to 30 lines, buffer size to 1000 lines, then scroll 970 lines down, and lines between 970 and 1000 still render bold/italic font and 24bit colored cubes properly.

In short, \e[32766H\e[${LINES}A will work for every buffer size (I hope) so I edited my comment above.

@OddMorning with your workaround, was your first line on startup able to display 256 colors correctly? For me any line after will display 256 colors but not the first.

@nickbudi Hmm, you're right, first line doesn't display 256 colors. But I just figured why, that was my mistake. \e[32766H moves cursor to the buffer + line count line and \e[${LINES}A moves cursor line count lines up. But I did not take into account current cursor position which shouldn't be included in line count so it moved cursor to the last line of the buffer area.
In short, \e[32766H\e[$((LINES - 1))A should work with first line too (at least it does for me).

The current guidance seems rather useless. The only way I can get it to work is if I paste the full path to wsl-con.cmd into the task, and it stops working after Ctrl+L. Was anyone able to actually get this to work and without spawning and extra tab that only exists to spawn a temporary-TrueColor tab?

Was this page helpful?
0 / 5 - 0 ratings