Displaying unix color on windows cmd (e.g. ←[31m)

时间秒杀一切 提交于 2020-01-31 08:53:18

问题


I've recently started doing some ruby on rails development on Windows 7 and have found a number of commands (rspec, guard, etc) output colour codes that just show up in text on the windows command line (or through Console2 which I use). eg:

←[31mrspec ./spec/views/users/index.html.erb_spec.rb:21←[0m ←[36m# users/index renders a list of users←[0m
←[31mrspec ./spec/requests/homes_spec.rb:9←[0m ←[36m# Homes GET /homes ←[0m
←[31mrspec ./spec/views/users/new.html.erb_spec.rb:13←[0m ←[36m# users/new renders new user form←[0m
←[31mrspec ./spec/views/users/show.html.erb_spec.rb:13←[0m ←[36m# users/show renders attributes in <p>←[0m

I'm aware you can turn the color off for most tools by taking the --color command out out of the config files (e.g. the .respc file), but it's a pain to have to do this for everything and colour coding would be nice.

Any ideas how I can get these to display properly in Windows?


回答1:


  1. Change Console2 to ConEmu (I'm the author of this console). It supports Ansi x3.64

  2. Or, you may use AnsiCon to enable Ansi




回答2:


I use Console2 ( http://sourceforge.net/projects/console/ ) with ansicon ( https://github.com/adoxa/ansicon ) and it work well :

  1. compile or download dll from author : http://ansicon.adoxa.cjb.net/ and put it in a repertory include in your path ;
  2. In console, launch ansicon : ansicon -i


来源:https://stackoverflow.com/questions/11743460/displaying-unix-color-on-windows-cmd-e-g-%e2%86%9031m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!