I often keep several R command-line interactive sessions running on my desktop at work, linked to vim with the vim-r-plugin (which is kind of like ESS). I use tmux to connect to them remotely, and also because vim-r-plugin depends on it. Sometimes while connecting remotely, however, long lines at the R prompt will fail to wrap properly: instead of being broken over multiple lines, the cursor will just start overwriting stuff at the beginning of the line. The wrapping location is not (necessarily) the same as the edge of my current terminal. All the commands appear to work as expected, so it's just a problem with display.

Other details that might help to diagnose the issue: Backspacing beyond the start of the line will actually go back a line, so unrelated stuff on the previous line will start disappearing/getting overwritten. The arrow keys will "wrap" normally around the end of this line, but will be off by one: going left beyond the start of the line brings the cursor to the right of the previous (unrelated) line. Also, when paging back through the command history, any that are too long will be wrapped in the same improper way, and paging back subsequently will move the cursor up a line.

Resizing the terminal to be narrower than where the break happens causes further problems. Text appears to wrap to the next line correctly, but there are still odd glitches: if I go back and edit the top line, then try to go to the bottom line, the cursor will no longer wrap beyond the right hand side of the first line. Paging back through the history looks even stranger: long commands are broken over multiple lines, but characters are missing from the middle and there is still overwriting on the bottom line. It kind of like two types of wrapping are going on simultaneously. Editing the top line causes unpredictable "redrawing" updates that make the command unreadable.

$TERM is screen-256color. I'm using Terminator as a terminal emulator and bash as my shell. R version is 3.3.1.

Things I have tried: sending "detach-client -a" and "set aggressive-resize" to tmux; changing the PS1 variable in my .bashrc. No effect. Exiting and re-entering the R session works but is a pain because I typically have large workspaces that take minutes to save and restore.

I am pretty sure R is using GNU readline for the command-line interactive sessions so I've added that as a tag as well.

Any fixes/workarounds? Thanks all!


This has been fixed/improved in R 3.3.2. See the relevant part of the NEWS file and the reported bug:


* Versions of the readline library >= 6.3 had been changed so that
  terminal window resizes were not signalled to readline: code has
  been added using a explicit signal handler to work around that
  (when R is compiled against readline >= 6.3).  (PR#16604)

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.