Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <h1 align="center">
  2. <br>
  3. <br>
  4. <img width="320" src="media/logo.svg" alt="Chalk">
  5. <br>
  6. <br>
  7. <br>
  8. </h1>
  9. > Terminal string styling done right
  10. [![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) ![TypeScript-ready](https://img.shields.io/npm/types/chalk.svg) [![run on repl.it](https://repl.it/badge/github/chalk/chalk)](https://repl.it/github/chalk/chalk)
  11. <img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
  12. <br>
  13. ---
  14. <div align="center">
  15. <p>
  16. <p>
  17. <sup>
  18. Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
  19. </sup>
  20. </p>
  21. <sup>Special thanks to:</sup>
  22. <br>
  23. <br>
  24. <a href="https://standardresume.co/tech">
  25. <img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
  26. </a>
  27. <br>
  28. <br>
  29. <a href="https://retool.com/?utm_campaign=sindresorhus">
  30. <img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="210"/>
  31. </a>
  32. <br>
  33. <br>
  34. <a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
  35. <div>
  36. <img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
  37. </div>
  38. <b>All your environment variables, in one place</b>
  39. <div>
  40. <span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
  41. <br>
  42. <span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
  43. </div>
  44. </a>
  45. </p>
  46. </div>
  47. ---
  48. <br>
  49. ## Highlights
  50. - Expressive API
  51. - Highly performant
  52. - Ability to nest styles
  53. - [256/Truecolor color support](#256-and-truecolor-color-support)
  54. - Auto-detects color support
  55. - Doesn't extend `String.prototype`
  56. - Clean and focused
  57. - Actively maintained
  58. - [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
  59. ## Install
  60. ```console
  61. $ npm install chalk
  62. ```
  63. ## Usage
  64. ```js
  65. const chalk = require('chalk');
  66. console.log(chalk.blue('Hello world!'));
  67. ```
  68. Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
  69. ```js
  70. const chalk = require('chalk');
  71. const log = console.log;
  72. // Combine styled and normal strings
  73. log(chalk.blue('Hello') + ' World' + chalk.red('!'));
  74. // Compose multiple styles using the chainable API
  75. log(chalk.blue.bgRed.bold('Hello world!'));
  76. // Pass in multiple arguments
  77. log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
  78. // Nest styles
  79. log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
  80. // Nest styles of the same type even (color, underline, background)
  81. log(chalk.green(
  82. 'I am a green line ' +
  83. chalk.blue.underline.bold('with a blue substring') +
  84. ' that becomes green again!'
  85. ));
  86. // ES2015 template literal
  87. log(`
  88. CPU: ${chalk.red('90%')}
  89. RAM: ${chalk.green('40%')}
  90. DISK: ${chalk.yellow('70%')}
  91. `);
  92. // ES2015 tagged template literal
  93. log(chalk`
  94. CPU: {red ${cpu.totalPercent}%}
  95. RAM: {green ${ram.used / ram.total * 100}%}
  96. DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
  97. `);
  98. // Use RGB colors in terminal emulators that support it.
  99. log(chalk.keyword('orange')('Yay for orange colored text!'));
  100. log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
  101. log(chalk.hex('#DEADED').bold('Bold gray!'));
  102. ```
  103. Easily define your own themes:
  104. ```js
  105. const chalk = require('chalk');
  106. const error = chalk.bold.red;
  107. const warning = chalk.keyword('orange');
  108. console.log(error('Error!'));
  109. console.log(warning('Warning!'));
  110. ```
  111. Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
  112. ```js
  113. const name = 'Sindre';
  114. console.log(chalk.green('Hello %s'), name);
  115. //=> 'Hello Sindre'
  116. ```
  117. ## API
  118. ### chalk.`<style>[.<style>...](string, [string...])`
  119. Example: `chalk.red.bold.underline('Hello', 'world');`
  120. Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
  121. Multiple arguments will be separated by space.
  122. ### chalk.level
  123. Specifies the level of color support.
  124. Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
  125. If you need to change this in a reusable module, create a new instance:
  126. ```js
  127. const ctx = new chalk.Instance({level: 0});
  128. ```
  129. | Level | Description |
  130. | :---: | :--- |
  131. | `0` | All colors disabled |
  132. | `1` | Basic color support (16 colors) |
  133. | `2` | 256 color support |
  134. | `3` | Truecolor support (16 million colors) |
  135. ### chalk.supportsColor
  136. Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
  137. Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
  138. Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
  139. ### chalk.stderr and chalk.stderr.supportsColor
  140. `chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
  141. ## Styles
  142. ### Modifiers
  143. - `reset` - Resets the current color chain.
  144. - `bold` - Make text bold.
  145. - `dim` - Emitting only a small amount of light.
  146. - `italic` - Make text italic. *(Not widely supported)*
  147. - `underline` - Make text underline. *(Not widely supported)*
  148. - `inverse`- Inverse background and foreground colors.
  149. - `hidden` - Prints the text, but makes it invisible.
  150. - `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
  151. - `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
  152. ### Colors
  153. - `black`
  154. - `red`
  155. - `green`
  156. - `yellow`
  157. - `blue`
  158. - `magenta`
  159. - `cyan`
  160. - `white`
  161. - `blackBright` (alias: `gray`, `grey`)
  162. - `redBright`
  163. - `greenBright`
  164. - `yellowBright`
  165. - `blueBright`
  166. - `magentaBright`
  167. - `cyanBright`
  168. - `whiteBright`
  169. ### Background colors
  170. - `bgBlack`
  171. - `bgRed`
  172. - `bgGreen`
  173. - `bgYellow`
  174. - `bgBlue`
  175. - `bgMagenta`
  176. - `bgCyan`
  177. - `bgWhite`
  178. - `bgBlackBright` (alias: `bgGray`, `bgGrey`)
  179. - `bgRedBright`
  180. - `bgGreenBright`
  181. - `bgYellowBright`
  182. - `bgBlueBright`
  183. - `bgMagentaBright`
  184. - `bgCyanBright`
  185. - `bgWhiteBright`
  186. ## Tagged template literal
  187. Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
  188. ```js
  189. const chalk = require('chalk');
  190. const miles = 18;
  191. const calculateFeet = miles => miles * 5280;
  192. console.log(chalk`
  193. There are {bold 5280 feet} in a mile.
  194. In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
  195. `);
  196. ```
  197. Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
  198. Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
  199. ```js
  200. console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
  201. console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
  202. console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
  203. ```
  204. Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
  205. All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
  206. ## 256 and Truecolor color support
  207. Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
  208. Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
  209. Examples:
  210. - `chalk.hex('#DEADED').underline('Hello, world!')`
  211. - `chalk.keyword('orange')('Some orange text')`
  212. - `chalk.rgb(15, 100, 204).inverse('Hello!')`
  213. Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
  214. - `chalk.bgHex('#DEADED').underline('Hello, world!')`
  215. - `chalk.bgKeyword('orange')('Some orange text')`
  216. - `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
  217. The following color models can be used:
  218. - [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
  219. - [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
  220. - [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
  221. - [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
  222. - [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
  223. - [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
  224. - [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
  225. - [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
  226. ## Windows
  227. If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
  228. ## Origin story
  229. [colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
  230. ## chalk for enterprise
  231. Available as part of the Tidelift Subscription.
  232. The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
  233. ## Related
  234. - [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
  235. - [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
  236. - [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
  237. - [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
  238. - [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
  239. - [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
  240. - [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
  241. - [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
  242. - [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
  243. - [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
  244. - [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
  245. - [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
  246. - [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
  247. - [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
  248. ## Maintainers
  249. - [Sindre Sorhus](https://github.com/sindresorhus)
  250. - [Josh Junon](https://github.com/qix-)