Home:ALL Converter>Check if using Windows console in Vim while in Windows Subsystem for Linux?

Check if using Windows console in Vim while in Windows Subsystem for Linux?

Ask Time:2019-07-13T06:52:07         Author:Foobar

Json Formatter

I am using Vim inside the Windows Subsystem for Linux. The windows command prompt has a bug which renders the background color incorrectly.

The fix is set t_ut=. Rather than applying this fix in all situations, I assume it would make sense to only apply it when Vim is being used inside the Windows console.

Unfortunately, I am not sure how to detect whether the Windows console is being used, because I am inside the Windows Subsystem for Linux.

Author:Foobar,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57014805/check-if-using-windows-console-in-vim-while-in-windows-subsystem-for-linux
Foobar :

I used the following code that implemented Roadowl's comment.\n\nlet uname = substitute(system('uname'),'\\n','','')\nif uname == 'Linux'\n if system('$PATH')=~ '/mnt/c/WINDOWS'\n \" We are in Windows Subsystem\n endif\nendif\n\n\nUpdate: I combined roadowl's and bk2204's answer:\n\nlet uname = substitute(system('uname'),'\\n','','')\nif uname == 'Linux'\n let lines = readfile(\"/proc/version\")\n if lines[0] =~ \"Microsoft\"\n return 1\n endif\nendif\n",
2019-07-13T00:44:26
yy