Neither `less` or `less -X` clear screen on exit

lessterminaltmuxvimzsh

Neither less or less -X clear screen on exit. At the same time, vim does….

Env iTerm2, protocol mosh, server Centos + tmux + zsh

iTerm2: report term as xterm-256color

tmux: set -g terminal-overrides 'xterm*:smcup@:rmcup@', no change to alternate-screen

$TERM is final set to screen-256color

I also tried
tput smcup | od -c and
tput rmcup | od -c

suggested here. It outputs correct answer.

Best Answer

The issue is my $LESS contains -X. Plus -+X will set less to it's default behavior, which is whatever is specified in $LESS, NOT no -X. Thus I was running less with -X all the time. That's why neither cleaned the screen.

Related Question