irritable_phd_syndrom irritable_phd_syndrom - 3 months ago 14
R Question

Clear terminal in R-3.2.1 on CentOS 6, put cursor on top

I am aware of this question having already been asked, however neither

cat("\014")
nor
Option + Command + L
works for me.
cls <- function() cat(rep("\n",50))
works, however the cursor remains at the bottom of the screen.

I am using OS X Mavericks for my local machine and I am running R remotely (via ssh). I am using Terminal.app on my local machine to do so.

Note :
Control + Command + L
works if I, if on the server side, I launch an X11 window (via
xterm
) and run R from there. However, I don't particularly like working in an X11 window.

Note : in my
.inputrc
I have
set editing-mode vi
. I'm not sure if that will effect clearing the screen. It does not seem to be an issue in the X11 window.

QUESTION : How would I clear the screen while remotely running the command line version of R from Terminal.app and have the cursor be at the top?

Answer

From this answer :

clear <- function() cat(c("\033[2J","\033[0;0H"))

Comments