简体   繁体   English

如何在Windows中设置TERM环境变量,以便通过SSH和Bit本地使用Bash?

[英]How to set TERM environment variable in Windows so that it works with Bash via SSH and locally with Git?

Background: 背景:

When using my Windows version of git in Powershell I found that I got the error "terminal is not fully functional" so I used the second solution posted here (ie change TERM to msys) to fix the problem. 在Powershell中使用我的Windows版本的git时,我发现我收到错误“终端功能不全”所以我使用了这里发布的第二个解决方案(即将TERM更改为msys)来解决问题。

However, this caused a secondary problem that when SSH'd into my Vagrant box, command line apps like Vim, Nano and even Clear would not run, producing errors "msys: unknown terminal type." 然而,这导致了一个次要问题,当SSH进入我的Vagrant盒子时,命令行应用程序如Vim,Nano甚至Clear都无法运行,从而产生错误“msys:unknown terminal type”。

I then attempted to change TERM to "ansi" and I got better results during ssh, in that the apps would run fine, but there are still formatting errors. 然后我尝试将TERM更改为“ansi”,并且在ssh期间我获得了更好的结果,因为应用程序运行正常,但仍然存在格式错误。

Question: 题:

Is there a setting for TERM in windows environment variables that will work properly for both my Windows copy of Git and the Vagrant VM Bash shell via SSH? Windows环境变量中是否有TERM设置,可以通过SSH为我的Windows副本Git和Vagrant VM Bash shell正常工作?

The combination that works best for me is: 最适合我的组合是:

:: set proper TERM to not break `vagrant ssh` terminal, 
:: see https://github.com/tknerr/bills-kitchen/issues/64
set TERM=cygwin

:: trick vagrant to detect colored output for windows, see here:
:: https://github.com/mitchellh/vagrant/blob/7ef6c5d9d7d4753a219d3ab35afae0d475430cae/lib/vagrant/util/platform.rb#L89
set ANSICON=true

:: mute the cygwin warning which otherwise comes on `vagrant ssh`
set CYGWIN=nodosfilewarning

(excerpt from the set-env.bat file from bills-kitchen ) (摘自set-env.bat -kitchenset-env.bat文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM