Liviu Andronic
2010-Feb-23 13:05 UTC
[R] colour highlighting inputs and outputs in the R terminal?
Dear all Is it possible to get basic colour highlighting for inputs and outputs in the R terminal? I am looking for something similar to what GUIs provide, such as JGR and (I think) the Windows R GUI: colouring all inputs in red, and all outputs in blue. All this in a colour-aware console (in my case, on Linux). I've been looking into xterm256 and highlight, but I am sofar unable to do with them what I would need. The closest I get to is with style() in xterm256:> require(xterm256) > cat( style( "hello world", bg = "black", fg = "blue"), "\n" )hello world The text will appear blue. What I would want to achieve, however, is to be able to define some global options for input fg and bg colours, and output fg and bg colours. Then, for any command that I would execute, say `mean(1:5)', I would get:> mean(1:10) ##in red[1] 5.5 ##in blue> summary(1:5) ##in redMin. 1st Qu. Median Mean 3rd Qu. Max. ##in blue 1 2 3 3 4 5 ##in blue Does anyone know a way to do this? Thank you Liviu -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
Hrishi Mittal
2010-Feb-23 14:00 UTC
[R] colour highlighting inputs and outputs in the R terminal?
Liviu, if you use Emacs + ESS, that provides colour highlighting. You can also have a script file alongside so that you have a saved command history in an R source file. See http://ess.r-project.org/ to get started. ----- Try http://prettygraph.com Pretty Graph , the easiest way to make R-powered graphs on the web. -- View this message in context: http://n4.nabble.com/colour-highlighting-inputs-and-outputs-in-the-R-terminal-tp1565865p1565909.html Sent from the R help mailing list archive at Nabble.com.
Marc Schwartz
2010-Feb-23 14:02 UTC
[R] colour highlighting inputs and outputs in the R terminal?
On Feb 23, 2010, at 7:05 AM, Liviu Andronic wrote:> Dear all > Is it possible to get basic colour highlighting for inputs and outputs > in the R terminal? I am looking for something similar to what GUIs > provide, such as JGR and (I think) the Windows R GUI: colouring all > inputs in red, and all outputs in blue. All this in a colour-aware > console (in my case, on Linux). > > I've been looking into xterm256 and highlight, but I am sofar unable > to do with them what I would need. The closest I get to is with > style() in xterm256: >> require(xterm256) >> cat( style( "hello world", bg = "black", fg = "blue"), "\n" ) > hello world > > The text will appear blue. What I would want to achieve, however, is > to be able to define some global options for input fg and bg colours, > and output fg and bg colours. Then, for any command that I would > execute, say `mean(1:5)', I would get: >> mean(1:10) ##in red > [1] 5.5 ##in blue >> summary(1:5) ##in red > Min. 1st Qu. Median Mean 3rd Qu. Max. ##in blue > 1 2 3 3 4 5 ##in blue > > Does anyone know a way to do this? Thank you > LiviuHi Liviu, I was not aware of Romain's xterm256 package, but from a quick review of the manual, it would appear to not support an automated syntax highlighting capability. One seems to need to explicitly print output to the console using his functions to be able to colorize it. Having used R on Windows, Linux and now OSX over the past 8+ years, I initially used ESS (http://ess.r-project.org/) on Windows and stayed with it on each subsequent platform. The terminal consoles are fine for quick and dirty coding and I will frequently use the terminal on OSX to test code for replying to a post here. But for routine use, I am in ESS, which provides syntax highlighting and so much more. On Windows and OSX, there are GUI interfaces that members of R Core have kindly provided which provide colorized output, but there is no parallel on Linux, other than third party options. Rather than using the terminal, I would recommend that you give serious consideration to using a full blown text editor, many of which already support R syntax highlighting and of course typical text editing features. In the most basic implementation, you can write your code in the editor and copy and paste it to the R console. With tighter integration, such as ESS, you can have split windows, with R code in one frame (say the upper half of the application window) and the R console running in an other one (say the lower half), both of which support R syntax highlighting. With a quick few keystrokes, you can submit the entire R code frame to the console or highlight sections of code and just submit that. Beyond that there is a lot other functionality (version control, LaTeX support, etc.) available that makes ESS an extremely efficient environment to use. If you prefer to not use or learn Emacs, there are other editors available such as Vim, Bluefish, Eclipse and many others available for Linux, some of which are listed here: http://www.sciviews.org/_rgui/projects/Editors.html JGR is also available for Linux: http://jgr.markushelbig.org/JGR_on_Linux.html HTH, Marc Schwartz
nikola
2012-Jun-27 16:49 UTC
[R] colour highlighting inputs and outputs in the R terminal?
that's an old thread but checkout the colorout package - it is awesome and it does exactly what you're asking for ! http://cran.r-project.org/web/packages/colorout/ -- View this message in context: http://r.789695.n4.nabble.com/colour-highlighting-inputs-and-outputs-in-the-R-terminal-tp1565865p4634653.html Sent from the R help mailing list archive at Nabble.com.