crayon
🖍️ R package for colored terminal output — now superseded by cli
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
â—‹CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
âś“.zenodo.json file
Found .zenodo.json file -
â—‹DOI references
-
â—‹Academic publication links
-
✓Committers with academic emails
2 of 18 committers (11.1%) from academic institutions -
â—‹Institutional organization owner
-
â—‹JOSS paper metadata
-
â—‹Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
🖍️ R package for colored terminal output — now superseded by cli
Basic Info
- Host: GitHub
- Owner: r-lib
- License: other
- Language: R
- Default Branch: main
- Homepage: http://r-lib.github.io/crayon/
- Size: 2.99 MB
Statistics
- Stars: 325
- Watchers: 6
- Forks: 39
- Open Issues: 0
- Releases: 7
Topics
Metadata Files
README.md
🚀 crayon is now superseded by the cli package. 🚀
Please use cli for new projects.
crayon is still supported and will receive important bug fixes, but no new features.
Stylish terminal output in R
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.
Installation
Stable version:
r
install.packages("crayon")
Development version:
r
pak::pak("r-lib/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
resetboldblurred(usually calleddim, renamed to avoid name clash)italic(not widely supported)underlineinversehiddenstrikethrough(not widely supported)
Text colors
blackredgreenyellowbluemagentacyanwhitesilver(usually calledgray, renamed to avoid name clash)
Background colors
bgBlackbgRedbgGreenbgYellowbgBluebgMagentabgCyanbgWhite
Screenshot on OSX

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 strings 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()) as well as RGB specifications via the
rgb() 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")

License
MIT @ Gábor Csárdi
Owner
- Name: R infrastructure
- Login: r-lib
- Kind: organization
- Repositories: 154
- Profile: https://github.com/r-lib
GitHub Events
Total
- Issues event: 4
- Watch event: 4
- Delete event: 1
- Issue comment event: 1
- Push event: 3
- Pull request event: 1
- Fork event: 1
- Create event: 1
Last Year
- Issues event: 4
- Watch event: 4
- Delete event: 1
- Issue comment event: 1
- Push event: 3
- Pull request event: 1
- Fork event: 1
- Create event: 1
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Gábor Csárdi | c****r@g****m | 252 |
| brodieG | b****G | 26 |
| Jim Hester | j****r@g****m | 6 |
| Kirill MĂĽller | k****r | 5 |
| Salim B | 2****b | 3 |
| Ista Zahn | i****n@h****u | 1 |
| Romain François | r****n@t****r | 1 |
| Chan-Yub Park | m****k@g****m | 1 |
| David Nusinow | d****w@g****m | 1 |
| Davis Vaughan | d****s@p****o | 1 |
| Davor Cubranic | c****c@s****a | 1 |
| Eamon O'Dea | o****5@g****m | 1 |
| Francois Michonneau | f****u@g****m | 1 |
| Maximilian MĂĽcke | m****n@g****m | 1 |
| Neal Fultz | n****z@g****m | 1 |
| Ramon Diaz-Uriarte | r****2 | 1 |
| Rich FitzJohn | r****n@g****m | 1 |
| Vince | v****r | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 81
- Total pull requests: 29
- Average time to close issues: 3 months
- Average time to close pull requests: about 2 months
- Total issue authors: 48
- Total pull request authors: 20
- Average comments per issue: 3.1
- Average comments per pull request: 2.76
- Merged pull requests: 25
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 3
- Average time to close issues: 27 days
- Average time to close pull requests: 34 minutes
- Issue authors: 2
- Pull request authors: 2
- Average comments per issue: 0.33
- Average comments per pull request: 0.33
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- gaborcsardi (19)
- brodieG (5)
- krlmlr (3)
- hadley (3)
- HenrikBengtsson (3)
- january3 (2)
- SchmidtPaul (2)
- pbreheny (2)
- jennybc (2)
- kforner (2)
- zx8754 (1)
- lindauer (1)
- M-E-Rademaker (1)
- ktiu (1)
- dbosak01 (1)
Pull Request Authors
- gaborcsardi (6)
- salim-b (3)
- krlmlr (3)
- jimhester (2)
- m-muecke (2)
- brodieG (2)
- richfitz (1)
- cubranic (1)
- nfultz (1)
- fmichonneau (1)
- vreuter (1)
- dnusinow (1)
- tiegz (1)
- dgkf (1)
- rdiaz02 (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- cran 774,453 last-month
- Total docker downloads: 212,578,013
-
Total dependent packages: 576
(may contain duplicates) -
Total dependent repositories: 1,644
(may contain duplicates) - Total versions: 30
- Total maintainers: 1
cran.r-project.org: crayon
Colored Terminal Output
- Homepage: https://r-lib.github.io/crayon/
- Documentation: http://cran.r-project.org/web/packages/crayon/crayon.pdf
- License: MIT + file LICENSE
-
Latest release: 1.5.3
published about 2 years ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/r-lib/crayon
- Documentation: https://pkg.go.dev/github.com/r-lib/crayon#section-documentation
- License: other
-
Latest release: v1.5.3
published about 2 years ago
Rankings
conda-forge.org: r-crayon
- Homepage: https://github.com/r-lib/crayon#readme
- License: MIT
-
Latest release: 1.5.2
published over 3 years ago
Rankings
Dependencies
- grDevices * imports
- methods * imports
- utils * imports
- mockery * suggests
- rstudioapi * suggests
- testthat * suggests
- withr * suggests
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- JamesIves/github-pages-deploy-action v4.4.1 composite
- actions/checkout v3 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v3 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite