/usr/lib/R/site-library/crayon/README.markdown is in r-cran-crayon 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | # Crayon - stylish terminal output in R
[![Linux Build Status](https://travis-ci.org/gaborcsardi/crayon.svg?branch=master)](https://travis-ci.org/gaborcsardi/crayon)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/github/gaborcsardi/crayon?svg=true)](https://ci.appveyor.com/project/gaborcsardi/crayon)
[![](http://www.r-pkg.org/badges/version/crayon)](http://cran.rstudio.com/web/packages/crayon/index.html)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/crayon)](http://cran.r-project.org/web/packages/crayon/index.html)
With crayon it is easy to add color to terminal output, create styles
for notes, warnings, errors; and combine styles.
ANSI color support is automatically detected and used. Crayon was largely
inspired by [chalk](https://github.com/sindresorhus/chalk).
## Installation
```r
devtools::install_github("gaborcsardi/crayon")
library(crayon)
```
## Styles
Crayon defines several styles, that can be combined. Each style in the list
has a corresponding function with the same name.
### General styles
* `reset`
* `bold`
* `blurred` (usually called `dim`, renamed to avoid name clash)
* `italic` (not widely supported)
* `underline`
* `inverse`
* `hidden`
* `strikethrough` (not widely supported)
### Text colors
* `black`
* `red`
* `green`
* `yellow`
* `blue`
* `magenta`
* `cyan`
* `white`
* `silver` (usually called `gray`, renamed to avoid name clash)
### Background colors
* `bgBlack`
* `bgRed`
* `bgGreen`
* `bgYellow`
* `bgBlue`
* `bgMagenta`
* `bgCyan`
* `bgWhite`
### Screenshot on OSX
![](/inst/ANSI-8-OSX.png)
## Usage
The styling functions take any number of character vectors as arguments,
and they concatenate and style them:
```r
library(crayon)
cat(blue("Hello", "world!\n"))
```
Crayon defines the `%+%` string concatenation operator, to make it easy
to assemble stings with different styles.
```r
cat("... to highlight the " %+% red("search term") %+% " in a block of text\n")
```
Styles can be combined using the `$` operator:
```r
cat(yellow$bgMagenta$bold('Hello world!\n'))
```
Styles can also be nested, and then inner style takes precedence:
```r
cat(green(
'I am a green line ' %+%
blue$underline$bold('with a blue substring') %+%
' that becomes green again!\n'
))
```
It is easy to define your own themes:
```r
error <- red $ bold
warn <- magenta $ underline
note <- cyan
cat(error("Error: subscript out of bounds!\n"))
cat(warn("Warning: shorter argument was recycled.\n"))
cat(note("Note: no such directory.\n"))
```
## 256 colors
Most modern terminals support the ANSI standard for 256 colors,
and you can define new styles that make use of them. The `make_style`
function defines a new style. It can handle R's built in color names
(see the output of `colors()`), and also RGB specifications, via the
`rbg()` function. It automatically chooses the ANSI colors that
are closest to the specified R and RGB colors, and it also has
a fallback to terminals with 8 ANSI colors only.
```r
ivory <- make_style("ivory")
bgMaroon <- make_style("maroon", bg = TRUE)
fancy <- combine_styles(ivory, bgMaroon)
cat(fancy("This will have some fancy colors"), "\n")
```
![](/inst/ANSI-256-OSX.png)
|