4

The problem:

  • I open a terminal (in Linux Mint, so mate-terminal)
  • zsh is the shell
  • Then I run tmux
  • Edit a file with nano
  • Scroll up and down that file with the cursor
  • Issue: When scrolling down in nano, only the bottom half of the terminal window gets refreshed
  • Issue: When scrolling up in nano, only the top half of the terminal windo gets refreshed

The complete nano view of file does not get refreshed in my terminal window when scrolling. Any tips?

Edit: my .tmux.conf

It seems that this line specifically is the culprit (as commenting it out fixes the problem):

set -g default-terminal "xterm-256color"

I'm pretty sure I added that line because I have issues even running nano during an SSH session.

Here is the full file:

set-option -g default-shell /bin/zsh

# Make sure tmux knows we're using 256 colours, for
# correct colourised output
set -g default-terminal "xterm-256color"

# The following were marked as "unknown", so
# I do know what I'm doing wrong.
#set -g mode-mouse on
#setw -g mouse-select-window on
#setw -g mouse-select-pane on

# Attempting to stop "alert" sound upon startup
# but none of these are working...
set-option bell-on-alert off
set-option bell-action none
set-option visual-bell off
5
  • I have realised that this happens regardless of being in an SSH connection or not. So SSH does not seem to be part of the problem. This brings it down to tmux, or my shell, I'm guessing.
    – eoinoc
    Sep 17, 2012 at 11:16
  • The shell doesn't matter. SSH was the most likely culprit (an unknown terminal type on the server), but that's not it… What's the value of TERM inside tmux (echo $TERM in the shell inside tmux)? Also, does echo $LINES return the correct number of lines? If you have a .tmux.conf, try without, and if it's the culprit, post its content. Sep 17, 2012 at 22:56
  • The value of TERM is xterm-256color. Lines says 39 (hmm, does that mean columns or rows?). Right you are, moving .tmux.conf fixes the issue, so I'm putting the contents above.
    – eoinoc
    Sep 18, 2012 at 19:58
  • 1
    tmux uses screen-256color by default. Changing TERM to something else within tmux may have unintended consequences. Make sure the terminfo entry for screen-256color is present on your system.
    – jw013
    Sep 18, 2012 at 20:06
  • I ended up with the value of screen for tmux, as screen-256color ended up with nano failing to launch during SSH sessions with the error: Error opening terminal: xterm-256color.
    – eoinoc
    Sep 24, 2012 at 14:19

2 Answers 2

9

From the tmux FAQ:

******************************************************************************
* PLEASE NOTE: most display problems are due to incorrect TERM! Before       *
* reporting problems make SURE that TERM settings are correct inside and     *
* outside tmux.                                                              *
*                                                                            *
* Inside tmux TERM must be "screen" or similar (such as "screen-256color").  *
* Don't bother reporting problems where it isn't!                            *
*                                                                            *
* Outside, it must match your terminal: particularly, use "rxvt" for rxvt    *
* and derivatives.                                                           *
******************************************************************************

http://tmux.git.sourceforge.net/git/gitweb.cgi?p=tmux/tmux;a=blob;f=FAQ

2
  • Set value to screen specifically, as screen-256color resulted in the error Error opening terminal: xterm-256color launching nano during SSH sessions.
    – eoinoc
    Sep 24, 2012 at 14:20
  • 1
    1+ Lifesaver! Made the switch from screen just now and this problem was bugging me big time.
    – user13742
    Oct 31, 2012 at 22:17
1

I had a very similar problem, but instead of nano I was using vim. I also compiled tmux from source (this detail will be important). I've been pulling my hair out trying to figure out the solution and while I don't know exactly why, I wanted to provide some steps I tried to finally get it working. What my problem was (adapted from original question):

  • I open a terminal (in CentOS 7, so gnome-terminal)
  • zsh is the shell
  • Then I run tmux
  • Edit a file with vim
  • Split the view in vim with :sp
  • Create a vertically split pane in tmux
  • Go back to file, scroll up and down that file with the cursor
  • Issue: When scrolling down in either vim viewport, only the very bottom of the viewport gets refreshed (only the line the cursor is on)
  • Issue: When scrolling up in either vim viewport, only the very top of the viewport gets refreshed (only the line the cursor is on)
  • Sometimes, however, I could get the bottom viewport to scroll properly if I adjusted the zoom of the terminal (Ctrl-minus or Ctrl-Shift-+)
  • Issue: Along with that, if I went to the new tmux pane and type in a bunch of text (with spaces), then went to the beginning of the command and used the delete key to delete some characters, the terminal would print a portion of the command on the very top line as I was still editing. And I wouldn't be able to get an accurate sense of what was actually being typed. No fun.

Here's what I did to eventually fix it: First, I would suggest making sure tmux is using the screen-256color TERM setting. Put this in your .tmux.conf:

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

Now close all of your tmux sessions. Reopen tmux and see if that somehow fixed the problem:

echo $TERM

Should say screen-256color. Unfortunately that wasn't enough for me, I was getting the same problems.

What ultimately fixed it for me was cloning the latest tmux version (at time of writing, v2.8) from github, then recompiling. I put this new build/binary in a separate directory, and lo and behold the new binary worked while the old one (unknown version) still didn't. The old one was still a pretty recent version, though.

1
  • Setting the $TERM in my docker containers on Ubuntu 18 resolved this issue for me with nano. Thank you! May 9, 2020 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.