How to enable ANSI colors in ConEmu + Git Bash?

I use Git Bash with ConEmu to make it look cool. However, when installing Composer, the colors seem to run away:

enter image description here

So Git Bash does not support all colors. Checking the AnsiColors256.ans file:

enter image description here

After a lot of searching on Google, I still haven't found a solution. I do not want to use Ansicon or another console emulator, ConEmu is suitable for me.

My settings:

  • ConEmuHk contributor included
  • Ansi X3.64 / xterm 256 included
  • Windows 7 x64
  • Git bash 1.9.5
  • ConEmu 141208

How to enable all colors? This annoys my need for a Console-Zen experience :(

+6
source share
3 answers

To correctly enable colors in Git Bash:

  • Download and extract ANSICON : https://github.com/adoxa/ansicon/releases/tag/v1.81
  • If you are using a 64-bit OS , copy everything to the x64 folder, otherwise,
    • If you are using a 32-bit OS , copy everything to the x86 folder.
  • Create the ANSICON folder in C: \ Program Files \ ANSICON and paste the copied content here.
  • Right-click on the Git Bash shortcut and go to Properties .

enter image description here

  1. Set / change the Target value as follows (see screenshot below):

"C: \ Program Files \ ANSICON \ ansicon.exe" "C: \ Program Files \ Git \ git- bash.exe" --cd-to-home

Change label target

  1. Open the .bashrc file (C: \ Users \ Aditya \ .bashrc).

NOTE. .bashrc is a hidden file. Therefore, you need to enable the option in the settings of Windows Explorer to display hidden files.

  1. Add the following 2 lines to your .bashrc file (anywhere):

unalias $ (alias | grep winpty | grep php | cut -d "=" -f1 | cut -d "" -f2)

export ANSICON = true

enter image description here

  1. Save the .bashrc file and open Git Bash. Done! composer team output php artisan color output - very difficult to get
+1
source

Launch ConEmu from Win R (enter the full path to sh.exe if necessary)

ConEmu -basic -cmd sh.exe -l -i 

Run composer , ANSI works.

ANSI is working

+3
source

Another problem that you may run into is setting up the task (Settings → Launch → Tasks) without quoting correctly. Performing a task like the following will disrupt the composer's ANSI layout (everything else seems to work very well):

 %TOOLS_DIR%\git\bin\sh.exe --login -i -new_console:C:%TOOLS_DIR%\git\mingw64\share\git\git-for-windows.ico:t:"Git bash" 

The %TOOLS_DIR% value is D:\Tools . I can only imagine that backslash problem. however, it works as expected:

 "%TOOLS_DIR%\git\bin\sh.exe" --login -i -new_console:C:"%TOOLS_DIR%\git\mingw64\share\git\git-for-windows.ico":t:"Git bash" 
0
source

Source: https://habr.com/ru/post/979971/


All Articles