git bash 无法解析ansi转义,着色终端

2019-10-14  本文已影响0人  嚼不烂的口香糖

问题

在windows 10上使用 git bash,在php的laravel项目目录下运行php artisan list出现如下乱码:

Laravel Framework ?[32m6.2.0?[39m

?[33mUsage:?[39m
  command [options] [arguments]

?[33mOptions:?[39m
  ?[32m-h, --help?[39m            Display this help message
  ?[32m-q, --quiet?[39m           Do not output any message
  ?[32m-V, --version?[39m         Display this application version
  ?[32m    --ansi?[39m            Force ANSI output
  ?[32m    --no-ansi?[39m         Disable ANSI output
  ?[32m-n, --no-interaction?[39m  Do not ask any interactive question
  ?[32m    --env[=ENV]?[39m       The environment the command should run under
  ?[32m-v|vv|vvv, --verbose?[39m  Increase the verbosity of messages: 1 for norm
al output, 2 for more verbose output and 3 for debug

在英文网站找到了解决的办法:
在git 的 .bashrc 文件加入如下内容:

##### Git Bash for Windows >= 2.x
 
# remove the winpty PHP aliases
unalias $(alias | grep winpty | grep php | cut -d"=" -f1 | cut -d" " -f2)
 
# support ansi color
export ANSICON=true

相关连接:https://blog.kmelia.net/testing/coloration-dans-git-bash/123

上一篇 下一篇

猜你喜欢

热点阅读