美文网首页
git bash 无法解析ansi转义,着色终端

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

作者: 嚼不烂的口香糖 | 来源:发表于2019-10-14 16:59 被阅读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

相关文章

网友评论

      本文标题:git bash 无法解析ansi转义,着色终端

      本文链接:https://www.haomeiwen.com/subject/sggrmctx.html