Codeception bash color output does not display - bash

I have been testing with Codeception and PhantomJS for a while, but when ever i have to debug and run
vendor/bin/codecept run --debug
with colors set to true all i get is:
Modules: ←[33mWebDriver, AcceptanceHelper←[39m
and so on... So for some reason the color is just outputed in a raw format and is not working at all. Colors usually work. like when i use "ls --color" it just works.
My System is Windows 7 i'm using the "git bash" and i have also tried the regular "cmd" "powershell" and "cygqwin". Neither one of them seem to work with codeceoptions output.
So what is the problem? I'm clueless :(

in bash, try running
export TERM=ansi
or
export TERM=xterm
before running your program
or, to test color output from the shell itself:
echo -e "\e[41m\e[32mCOLOR\e[0m"
if that does work than it is the program, not the environment
finally, you might just need a better console.
try conemu, it has excellent ansi color support and i use it for cmd powershell bash perl and ssh sessions :)
http://sourceforge.net/projects/conemu/

Your application (Codeception) was not adapted to Windows console, which doesn't support ANSI colorizing. To enable ANSI colors you may choose one of the following options:
ConEmu is the Windows local terminal with ANSI capabilities and many other features like tabs, splits, preconfigured shell tasks, ... Also, it's the only terminal which able to "replace" default Windows console. Yep, I'm the author.
Some applications may work properly in mintty (bundled with cygwin or msys). Many native Windows console tools can't work properly in this terminal, but may be your app will be fine.
There is AnsiCon project. It enables ANSI colorizing in standard Windows console.
BTW, bash's ls (cygwin or msys) was adapted to Windows console API, so it doesn't post ANSI to terminal, unless terminal has done special initialization of POSIX subsystem. ConEmu can do this initialization via cygwin/msys connector.

Related

Use Windows Terminal on PhpStorm?

I would like to know how to use Windows Terminal on PhpStorm?
I went to "Settings> Terminal", and tried to change the terminal path to :
C:\Users\user\AppData\Local\Microsoft\WindowsApps\Microsoft.WindowsTerminal_8wekyb3d8bbwe\wt.exe
But no effects
I don't think it's possible: Windows Terminal is not a shell, it's a terminal emulator that has its own window/UI. It is just another front end to the existing shells that runs a shell (powershell, cmd, wsl) under the hood. PhpStorm provides its own terminal emulator in Terminal tool window. It's impossible to integrate one terminal emulator inside another, because all integration is based on parsing ANSI/VT sequences from underlying shell.

xterm-256 support for git bash

I am trying to enable xterm 256 color via git bash. It turns out there are 2 ways to start a git bash in Windows.
windows cmd, run this git-cmd.exe --command=usr/bin/bash.exe -l -i
mintty, run git-bash.exe
However seems only the second one support 256 color. The following screenshot is executing result of cat AnsiColors256.ans AnsiColors256.ans.
But the downside of git-bash.exe is that it can't be integrated into integraded command line tool like ConEmu, as indicated on ConEMU Doc
Also, you may run in ConEmu tab git-bash.exe, but this is not recommended, because it runs mintty.exe, which is another terminal.
It actually start an new window instance.
My question is, is there any tweak to config cmd.exe to support 256 color like mintty.exe? I still want to use a single ConEMU instance for all my command line interfaces.
I am using windows git version git version 2.24.0.windows.2
It actually start an new window instance.
a simple "bash" would not start a new windows.
As for the CMD.exe, you might consider using instead the new Microsoft Terminal, as Microsoft/Terminal, which is more likely to support 24-bit colors.

Run msys2 shell in VSCode terminal

I am working with (a customized install of) msys2, and I would like to make it run in the VSCode integrated terminal. However, it doesen't seem to want to run there. Unlike normal msys, it has msys2_shell.bat & msys2_shell.cmd. It seems to always open up a separate shell window, but I don't want this to always happen, I would like to keep it integrated so I can use shortcuts and such. I already tried the -no-start option. Any suggestions?
Thanks!
msys2_shell.cmd -no-start -defterm could work. Other than that, you can invoke Bash directly if you remember to set MSYSTEM and invoke a login shell: C:\msys64\usr\bin\env MSYSTEM=MSYS /usr/bin/bash -li
For more details, see https://www.msys2.org/wiki/Launchers/.

Can not install Windows Service from Bash script [duplicate]

I have a small utility script called clear.bat that does some housekeeping work on my sources.
It is a .bat file so that I could easily double-click it in Windows Explorer.
Sometimes, I find it more handy to execute it from my Git bash (msysgit, if this matters).
To do this, I type
cmd
clear.bat
exit
cmd turns my Git bash into a normal cmd window where I could easily execute my batch. When I type exit, the cmd environment is terminated and I'm back in my Git bash.
Could this be achieved in an easier way?
I tried cmd /C clean.bat since the docs say
Syntax
CMD [charset] [options]
CMD [charset] [options] [/c Command]
CMD [charset] [options] [/k Command]
Options
/C Run Command and then terminate
/K Run Command and then return to the CMD prompt.
This is useful for testing, to examine variables
Edit:
Just noticed that the post is broken.
What I want is to execute clean.bat from within the Git bash without having to type the three commands above (cmd, clear.bat, exit). I just want to execute the .bat file from within my Git bash. Obvious way would be to create a separate .sh file that does the same work but this will lead to double code.
Edit 2:
When I execute cmd /C clean.bat, the Git bash turns into a plain CMD environment and only displays the prompt. The file clean.bat does not get executed. It's the same as if I just type cmd.
Also, adding a /debug switch does literally nothing. Seems like only cmd gets evaluated and all further parameters are getting ignored.
After playing around a bit more, I found the solution myself:
cmd "/C clean.bat"
does the trick. But I got no clue, why...
./clear.bat will do the trick.
The Git for Windows (msysGit has been superseded by Git for Windows1) FAQ says you have 3 options:
Run programs that have problems using the winpty utility. This allows you to keep using the nicer mintty terminal, but can become unwieldy if you need the workaround for many programs.
Modify the shortcut for Git Bash to run bash directly without mintty so it uses the default console host and configure it for "Quick Edit", reasonable size and scroll-back and suitable unicode font. You'll still have to live with the other quirks of console host.
Install and use ConEmu.
At some point, Git for windows added support for the MSYS_NO_PATHCONV environment variable, so in addition to #eckes and #AlikElzin-kilaka solutions, you can also
MSYS_NO_PATHCONV=1 cmd /c clean.bat
In general, I prefer this solution, as it allows the code to be the closest to resembling normal bash, and there are many ways to export MSYS_NO_PATHCONV depending on your preferred situation.
Note: Git for Window's bash does not support the MSYS2 environment variable MSYS2_ARG_CONV_EXCL
The other solutions
The weird quoting solution
Why does cmd "/c clean.bat" not create other errors?
It turns out argument parsing in windows does not follow the same universal rules as it does in *nix. Instead, in windows the arguments are parsed differently based on the runtime you compile against. Basically in windows, the command line arguments are passed in as "one string" and then parsed by the runtime.
See here(archive) for more explanation than you could ever want.
E.g. cmd parses arguments differently then wscript.exe
In the end, you can hopefully find something that works with this method, and it is the most "window-esque" of the three solutions
The // method
This is pretty well explained here and simple to use, but adds an extra / which does not help readability
I like start clean, it opens a new window with cmd. This method has some benefits:
cmd.exe gets a native console
the new console has a native windows character encoding (e.g. cp1251 vs utf8)
This will work and it frees the terminal too
nohup ./nucleus.bat &
less nohup.out

How to load ANSI escape codes or get coloured file listing in WinXP cmd shell?

This is related to this question : How to get coloured file listing in windows cmd shell ?
I'm trying to get, wouldn't you believe it, coloured file listing in windows cmd shell. Windows are XP SP2, if that matters.
In the old DOS days there used to be little programs like hdir, adir and such which displayed that nice. Nowadays, such programs are no more.
There is however, ls, from unixkit-tiny or unixtools. Unfortunatelly, it uses ANSI escape codes for displaying colours, and cmd doesn't handle those too well.
There are several solutions which include loading ansi.sys and command.com, but command.com doesn't handle long filenames that well, and is awfully slow. Even then sometimes it has problems displaying colours.
So what I'm asking, is there a way to get coloured file listing in windows cmd shell, apart from using cygwin ? Or is there a way to get ANSI escape codes to work with cmd.exe in a way so that native ls will play nicely ?
I ran across ANSICON at http://adoxa.110mb.com/ansicon/index.html ansicon github repo
Using it to colorize NAnt output. ls --color is being processed correctly.
Source code is provided, but I haven't examined it.
Actually I reckon A+ for ansicon -- Use
ansicon.exe -I
Installs it as a filter on your CMD.exe sessions. Works a treat with HTTY (ruby gem).
:-)
You could start the builtin Telnet server, firewall it to only allow localhost access, and use a telnet client that understands such escapes - even the native one. (I know, an ugly hack.)
It's possible to patch cmd.exe....
http://gynvael.coldwind.pl/?id=130&lang=en

Resources