Can't enable 256 colors in ConEmu

16,906

Solution 1

Bash does not send ANSI sequences to console. It tries to process them itself. And, because *nix terminal is generally only 8-color (not taking into account 256-color mode), bash uses 8-color palette instead of 16-color palette which is common to Windows terminal.

I think, 256-colors works in mintty because _isatty returns zero in that terminal. But it returns non zero value under ConEmu. May be in future builds I solve this puzzle (how to create real terminal with PTY features for some applications).

As for the question

You have no need in 256-colors In fact. To redefine prompt palette you may use "Extend foreground colors with background" feature. In breaf - set up colors 16, 17, etc. in ConEmu, set prompt background in bash to #5 (configurable in ConEmu), and voila.

There was a small bug in ConEmu "Extend..." processing. Use build 121016 or later.

PS1="\e[30;45m\u@\h \e[34;45m$PWD \[\e[0m\] > "

ConEmu and real console window

ConEmu settings

Following info does not match the question, but may be useful

Current version does not support 256-color mode in 'whole' console buffer (limitation, yes, removing it in plans).

So, you can go 2 ways

  • totally disable scrollback buffer (many ways, for example "cmd -cur_console:h0")
  • work in the bottom of the scroll-buffer.

Solution 2

I also couldn't get 256 color support to work (the colors would show up, but they looked the same as the 16-color palette). I switched to the "xterm" color scheme and now it works in native Windows executables (such as Python) but not in anything that uses Cygwin. Cygwin appears to have terminal-escape-sequence processing that you can't turn off, which defeats the ConEmuHk injection.

This is documented on the ConEmu wiki, here.

Solution 3

I had this weird problem and the weird solution and somehow it works. and don't know if this is with others too, just some info-sharing in case this shall be helpful.

I like colouring my consoles and like to utilize the full real 256 bits of RGB colouring. After confuguring as in the conemu/CMDer (i used the forked one) instruction. my 256bit coloring test looked like this.enter image description here. After mucking around a bit and testing with my bash 256bit capability. i.e running this command:

for i in {1..16384}; do echo -en "\e[38;5;${i}mTest";done

*note supposed to be {1..256}, but i had to force it for a longer colour prints, so just took a longer random number.. giving the result: enter image description here

But running some 2-3 times, i saw this clean gray shade suddenly enter image description here

and it worked then on.. enter image description here

weird but i got this working. Could it be that CMDer is somehow not using the full 256 bit because of optimizing reason and it get triggered when it is kicked in??,

PS: my CMDer cmd for the console:

-cur_console:fp -cur_console:d:"C:\WS":P:"<Cobalt>":t:"test":C:"C:\Arbeit\tools\Iconka-Buddy-Ninja.ico" set "PATH=%ConEmuDrive%\Program Files\Git\usr\bin;%PATH%" & "%ConEmuDrive%\Program Files\Git\git-bash.exe" --no-cd --command=%ConEmuBaseDirShort%\conemu-msys2-64.exe /usr/bin/bash.exe -l -i
Share:
16,906

Related videos on Youtube

RafaelGP
Author by

RafaelGP

Updated on June 12, 2022

Comments

  • RafaelGP
    RafaelGP about 2 years

    I'm trying to get 256 colors in the fantastic ConEmu-Maximus5 console.

    Update: Now it only shows 8 colors. I know because '$tput colors' output is '8'

    I have followed the instructions and activated:

    • TrueMod (24-bit color) support
    • Inject ConEmuHk
    • ANSI x3.64 / xterm 256 colors

    I don't understand what to do with 'check off whether the buffer / slide.'

    • I'm in windows 7.
    • I start ConEmu with a custom direct link, so it loads cygwin bash file.
    "C:\Program Files\ConEmu\ConEmu64.exe" /cmd ""C:\cygwin\bin\bash.exe" --login -i"
    
    • In my bashrc profile I have -> export TERM=cygwin
    • This is my custom command prompt:
        function prompt {
    
        local RED="\[\033[0;31m\]"
        local GREEN="\[\033[0;32m\]"
        local COOLRED="\e[38;5;173m"
        local COOLGREEN="\e[38;5;113m"
        PS1="$COOLRED\u@\h $LIGHT_COOLGREEN\$PWD \[\e[0m\] > "
    
        }
    
        prompt
    
    • The value of ConEmuANSI in ON, by the way.

    I have some screen shots:

    enter image description here

    As you can see the command prompt looks very extravagant because it doesn't like the 256 color settings. If i substitute the variables COOLRED and COOLGREEN with RED and GREEN, then it looks ok, but it's not 256 colors.

    More screenshots of the settings:

    enter image description here enter image description here

    And the last sceen shot it's cygwin's mintty. Everything is ok there. Full 256 color supported. It's a shame mintty doesn't have tabs. That's mostly the reason why I'm trying to move to ConEmu.

    enter image description here

    Thank you very much for helping!!!

    • Maximus
      Maximus over 11 years
      Explain to the nub ;) What file should I create in bash to redefine prompt?
    • RafaelGP
      RafaelGP over 11 years
      Just create a file called .bashrc in your home directory
    • Maximus
      Maximus over 11 years
      Weird. ".bashrc" does not working, but ".profile" do.
    • Maximus
      Maximus over 11 years
      More weird. Bash does not send Esc to console, but rather it trying to process them itself. Here you are - 8 colors.
    • RafaelGP
      RafaelGP over 11 years
      This thread explains about .bashrc .bash_profile and .profile
    • qwertzguy
      qwertzguy about 8 years
      Does ConEmu now support 256 colors?
  • RafaelGP
    RafaelGP over 11 years
    Thanks for your reply. I tried your variables, but still no luck. I've tried removing my custom color prompt, just in case, and when I print AnsiColors256.ans looks like it only can display 8 colors.
  • RafaelGP
    RafaelGP over 11 years
    Thanks for your hard work. It's true I don't really need 256 colors. I just need about 16 good looking ones, and I can do that in the colors section. Cheers!
  • antitoxic
    antitoxic about 11 years
    @Maximus I would be happy to see 256 colours in ConEmu - I want to be able to see full capacitly of LS_COLORS for example
  • Qix - MONICA WAS MISTREATED
    Qix - MONICA WAS MISTREATED almost 9 years
    Bash does not send ANSI codes to the console could you elaborate on this? Because afaik that is incorrect.
  • Qix - MONICA WAS MISTREATED
    Qix - MONICA WAS MISTREATED almost 9 years
    \e is usually analogous to the escape character and are indeed required. They have nothing to do with printf.