ansi strip

For platform.

Strip ANSI escape sequences from a string.

Command Type

built-in

Signature

> ansi strip {flags} ...rest

Parameters

  • ...rest: For a data structure input, remove ANSI sequences from strings at the given cell paths.

Input/output types:

input output
string string
list<string> list<string>
table table
record record

Examples

Strip ANSI escape sequences from a string

> $'(ansi green)(ansi cursor_on)hello' | ansi strip
hello

Strip ANSI escape sequences from a record field

> { greeting: $'hello (ansi red)world' exclamation: false } | ansi strip greeting
╭─────────────┬─────────────╮
│ greeting    │ hello world │
│ exclamation │ false       │
╰─────────────┴─────────────╯

Strip ANSI escape sequences from multiple table columns

> [[language feature]; [$'(ansi red)rust' $'(ansi i)safety']] | ansi strip language feature
╭───┬──────────┬─────────╮
│ # │ language │ feature │
├───┼──────────┼─────────┤
│ 0 │ rust     │ safety  │
╰───┴──────────┴─────────╯

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.