laravel工匠命令颜色不显示 [英] laravel artisan commands colors not showing
问题描述
使用laravel artisan命令时,我没有得到预期的颜色输出.
When using laravel artisan commands, I don't get the expected color output.
如果您查看 http://laravel.com/docs/4.2/commands , 它说:要将输出发送到控制台,您可以使用info,comment,question和error方法.每种方法都将使用适当的ANSI颜色作为其用途."
If you look at http://laravel.com/docs/4.2/commands , it says "To send output to the console, you may use the info, comment, question and error methods. Each of these methods will use the appropriate ANSI colors for their purpose."
但是使用终端薄荷糖或cmd,我看不到那些颜色.
But using terminals mintty or cmd, I don't get those colors.
例如,$this->error('Something went wrong!');
应该输出带有红色背景的文本.
For instance, $this->error('Something went wrong!');
should output the text with a red background.
缺少什么才能获得此颜色功能?
What is missing so that I get this color functionality ?
推荐答案
我知道这是一个旧答案,但是这里的其他答案并不是那么好
您已经发现,Windows的本机命令行不支持ANSI颜色. 在这里您可以找到另一个具有更多详细信息和有用链接的SO答案,但这是关键摘录:
As you've discovered, the native Windows command line doesn't support ANSI colors. Here you can find another SO answer with more details and useful links, but here is a crucial excerpt:
ANSI.SYS还可以在NT派生系统中用于16位旧程序 在NTVDM下执行.
ANSI.SYS also works in NT-derived systems for 16-bit legacy programs executing under the NTVDM.
Win32控制台本身不支持ANSI转义序列 全部.但是,诸如 Ansicon 之类的软件可以充当 标准的Win32控制台,并增加了对ANSI转义序列的支持.
The Win32 console does not natively support ANSI escape sequences at all. Software such as Ansicon can however act as a wrapper around the standard Win32 console and add support for ANSI escape sequences.
解决方案(简单):
Ansicon
如摘录中所述,软件Ansicon用于向Windows终端添加对ANSI颜色的支持.我没有使用过它,但是它似乎为现有的控制台添加了功能.
The solution (easy):
Ansicon
As mentioned in the excerpt, the software Ansicon is used to add support for ANSI colors to windows terminals. I haven't used it, but it seems to add functionality to existing consoles.
ANSICON为Windows控制台程序提供ANSI转义序列. 它提供的功能与ANSI.SYS针对MS-DOS的功能相同.
ANSICON provides ANSI escape sequences for Windows console programs. It provides much the same functionality as ANSI.SYS does for MS-DOS.
也就是说,要进行ANSI颜色编码时,您似乎需要运行ansicon
命令:
That said, you seem to need to run the ansicon
command when you want ANSI color coding:
例如,要显示file.ans,默认使用青色上的黑色 颜色:
For example, to display file.ans using black on cyan as the default color:
ansicon -m30 -t file.ans
另一种解决方案(更简单):
cmder
Another solution (easier):
cmder
如您所见,它支持ANSI颜色,但是它还内置了许多其他简洁功能.它还模拟了一些Unix功能.
As you can see it supports ANSI colors, but it also has many other neat features built-in. It emulates some Unix functionality, too.
到目前为止,我是我的最爱.
Cmder is by far my personal favorite.
这篇关于laravel工匠命令颜色不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!