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.

smcupandrmcupintmux, and now they're not working? That seems to be expected. – Mikel Sep 19 '14 at 02:46set -g terminal-overrides 'xterm*:smcup@:rmcup@'in my .tmux.conf. less -X still doesn't clear screen. – Jiesi Luo Sep 19 '14 at 15:52less -Xisn't supposed to clear the screen. What happens without the-Xoption? – Mikel Sep 19 '14 at 15:54less -Xclear the screen whilelessnot? Anyway, I testedless, it still didn't work. So basicallylessandless -Xboth don't clear screen in any case I tested. – Jiesi Luo Sep 19 '14 at 15:56lesssendssmcupon startup, andrmcupon exit, so after you quitless, you are taken back to your shell and can see your shell output but not what you were viewing inless. The-Xflag disables sending those terminal escapes, so thelessoutput is mixed in with your shell output. – Mikel Sep 19 '14 at 16:02lessstill doesn't work here? – Jiesi Luo Sep 19 '14 at 16:18type less,echo $LESSendecho $LESSOPEN? – jimmij Sep 19 '14 at 16:33less -+X somefileclear the screen? – Gilles 'SO- stop being evil' Sep 19 '14 at 21:24@jimmij
– Jiesi Luo Sep 19 '14 at 23:50type less:less is an alias for less -R less is /usr/bin/less;$LESSis-F -g -i -M -R -S -w -X -z-4.$LESSOPENis| /usr/bin/env lesspipe.sh %s 2>&-$LESSless somefile will clear screen on exit. I don't know whyless -+Xdoesn't work when$LESSis set though.. It should looking from man page.. Maybe a bug forless– Jiesi Luo Sep 19 '14 at 23:58-Xthere as I suspected, so basically you startedless -Xall the time. – jimmij Sep 20 '14 at 10:58