Windows Subsystem Linux, tmux and vim

June 30th, 2019

Phew! I had quite the adventure through an interesting array of tech yesterday, and I'm pleased to report I survived, and the prognosis was sucessful (sic).

In other words, I was able to get debian runnning on Windows 10, via cmder. But... then when using vim within tmux there were all sorts of nasty artifacts left over when scrolling. My first thought it must be wsl related, but I found many reports of tmux and vim having issues.

I'd seen some confusion surrounding tmux settings before, but the fix was usually pretty easy, like telling tmux what type of terminal it should emulate. I tried many settings, in tmux, and vim, to no avail, for a couple hours. For example, I tried changing the term from xterm to xterm-256colors to screen-256colors:

set -g default-terminal "screen-256colors"

I checked the locale:

set -gq status-utf8 on

And did a dpkg-reconfigure locales

Also tried set ttyfast in vim, and even fiddled with my nvidia card settings. No luck. I love tmux and vim. Not a major deal but its bugged me :-)

I was able to get to the source of the problem, the underlying TERM setting within the cygwin terminal of cmder. This is whats working for me:

if [ "$SHLVL" = "1" ] && [ "$is_wsl" = "1" ]; then
    export TERM=vwmterm

(the is_wsl comes from a thread I found about standardizing a way to check if a shell was running in Windows Linux):

read os </proc/sys/kernel/osrelease || :
if [[ "$os" == *Microsoft ]]; then

These resources may help other troubleshooters:

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022