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

问题

在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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容