2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: ansi
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Output ANSI codes to change color.
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
```> ansi (code) --escape --osc --list```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `code`: the name of the code to use like 'green' or 'reset' to reset the color
|
|
|
|
- `--escape`: escape sequence without the escape character(s)
|
|
|
|
- `--osc`: operating system command (ocs) escape sequence without the escape character(s)
|
|
|
|
- `--list`: list available ansi code names
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Examples
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
Change color to green
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
|
|
|
> ansi green
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Reset the color
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
|
|
|
> ansi reset
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Use ansi to color text (rb = red bold, gb = green bold, pb = purple bold)
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo [(ansi rb) Hello " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str collect
|
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-03-04 13:10:09 +01:00
|
|
|
Use ansi to color text (italic bright yellow on red 'Hello' with green bold 'Nu' and purple bold 'World')
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo [(ansi -e '3;93;41m') Hello (ansi reset) " " (ansi gb) Nu " " (ansi pb) World (ansi reset)] | str collect
|
|
|
|
```
|
|
|
|
|
|
|
|
Use ansi to color text with a style (blue on red in bold)
|
|
|
|
```shell
|
|
|
|
> $"(ansi -e { fg: '#0000ff' bg: '#ff0000' attr: b })Hello Nu World(ansi reset)"
|
|
|
|
```
|