31

Can we get syntax highlighting for R in the Terminal?

4 Answers 4

36

I've finally found a library that meets my needs.
Now I'm much happier with my coding environment.

colorout is an R package that colorizes R output when running in a terminal emulator.The package cannot be on CRAN because it changes code already loaded by R and this is prohibited by the CRAN Repository Policy. The package replaces the functions that output results and messages to R Console, and this is necessary because we cannot colorize the output without replacing these functions. To install it, do the following in R:

install.packages("devtools")
devtools::install_github("jalvesaq/colorout")
library("colorout")
# do something
2
5

Use something like ess on emacs or RStudio for syntax highlighting for R instead of expecting it to work in the terminal.

2

Another option now would be to use radian instead of the default R prompt.

0

As hd1 indicated, this is not an R question. You're asking the OSX Terminal.app to do something it's not capable of. A quick look around Google (happy Zamboni birthday!) shows Vim syntax Highlighting for highlighting within vim , or https://superuser.com/questions/72057/terminal-emulator-with-custom-color-palette , but dunno if these will run under Darwin.

EDIT: I can't stay away from the search :-) . So check out these threads: https://superuser.com/questions/400360/syntax-highlighting-in-terminal-mac-os-x , http://forums.macrumors.com/showthread.php?t=412609 , and a recommendation to install zsh , https://apple.stackexchange.com/questions/12161/os-x-terminal-must-have-utilities

3
  • 1
    Mac OS X comes with zsh out of the box.
    – hd1
    Commented Jan 16, 2013 at 13:49
  • @hd1 Oops-- I quoted the wrong thing. The special goody is "oh-my-zsh" or some such enhancement app. Commented Jan 16, 2013 at 15:02
  • @hd1 yup, that's the one. Commented Jan 16, 2013 at 16:00

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