Skip to content

Commit

Permalink
Update syntax highlighting for commands docs from shell to nu (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer authored Oct 2, 2023
1 parent 63ee848 commit 014f851
Show file tree
Hide file tree
Showing 466 changed files with 1,470 additions and 1,470 deletions.
4 changes: 2 additions & 2 deletions commands/docs/alias.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ usage: |
## Examples

Alias ll to ls -l
```shell
```nu
> alias ll = ls -l
```

## Notes
This command is a parser keyword. For details, check:
https://www.nushell.sh/book/thinking_in_nu.html
https://www.nushell.sh/book/thinking_in_nu.html
8 changes: 4 additions & 4 deletions commands/docs/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ usage: |
## Examples

Check if each row's status is the string 'UP'
```shell
```nu
> [[status]; [UP] [UP]] | all {|el| $el.status == UP }
true
```

Check that each item is a string
```shell
```nu
> [foo bar 2 baz] | all {|| ($in | describe) == 'string' }
false
```

Check that all values are equal to twice their index
```shell
```nu
> [0 2 4 6] | enumerate | all {|i| $i.item == $i.index * 2 }
true
```

Check that all of the values are even, using a stored closure
```shell
```nu
> let cond = {|el| ($el mod 2) == 0 }; [2 4 6 8] | all $cond
true
```
14 changes: 7 additions & 7 deletions commands/docs/ansi.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,37 @@ usage: |
## Examples

Change color to green (see how the next example text will be green!)
```shell
```nu
> ansi green
```

Reset the color
```shell
```nu
> ansi reset
```

Use different colors and styles in the same text
```shell
```nu
> $'(ansi red_bold)Hello(ansi reset) (ansi green_dimmed)Nu(ansi reset) (ansi purple_italic)World(ansi reset)'
Hello Nu World
```

The same example as above with short names
```shell
```nu
> $'(ansi rb)Hello(ansi reset) (ansi gd)Nu(ansi reset) (ansi pi)World(ansi reset)'
Hello Nu World
```

Use escape codes, without the '\x1b['
```shell
```nu
> $"(ansi -e '3;93;41m')Hello(ansi reset)" # italic bright yellow on red background
Hello
```

Use structured escape codes
```shell
```nu
> let bold_blue_on_red = { # `fg`, `bg`, `attr` are the acceptable keys, all other keys are considered invalid and will throw errors.
fg: '#0000ff'
bg: '#ff0000'
Expand Down Expand Up @@ -141,4 +141,4 @@ Operating system commands:
| -------------------------------------------------- | ------- | ------------------------------------------------------------------ |
| [`ansi gradient`](/commands/docs/ansi_gradient.md) | Builtin | Add a color gradient (using ANSI color codes) to the given string. |
| [`ansi link`](/commands/docs/ansi_link.md) | Builtin | Add a link (using OSC 8 escape sequence) to the given string. |
| [`ansi strip`](/commands/docs/ansi_strip.md) | Builtin | Strip ANSI escape sequences from a string. |
| [`ansi strip`](/commands/docs/ansi_strip.md) | Builtin | Strip ANSI escape sequences from a string. |
10 changes: 5 additions & 5 deletions commands/docs/ansi_gradient.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ usage: |
## Examples

draw text in a gradient with foreground start and end colors
```shell
```nu
> 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff'
```

draw text in a gradient with foreground start and end colors and background start and end colors
```shell
```nu
> 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff' --bgstart '0xe81cff' --bgend '0x40c9ff'
```

draw text in a gradient by specifying foreground start color - end color is assumed to be black
```shell
```nu
> 'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff'
```

draw text in a gradient by specifying foreground end color - start color is assumed to be black
```shell
```nu
> 'Hello, Nushell! This is a gradient.' | ansi gradient --fgend '0xe81cff'
```


**Tips:** Command `ansi gradient` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `ansi gradient` was not included in the official binaries by default, you have to build it with `--features=extra` flag
8 changes: 4 additions & 4 deletions commands/docs/ansi_link.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ usage: |
## Examples

Create a link to open some file
```shell
```nu
> 'file:///file.txt' | ansi link --text 'Open Me!'
Open Me!
```

Create a link without text
```shell
```nu
> 'https://www.nushell.sh/' | ansi link
https://www.nushell.sh/
```

Format a table column into links
```shell
```nu
> [[url text]; [https://example.com Text]] | ansi link url
```


**Tips:** Command `ansi link` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `ansi link` was not included in the official binaries by default, you have to build it with `--features=extra` flag
2 changes: 1 addition & 1 deletion commands/docs/ansi_strip.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ usage: |
## Examples

Strip ANSI escape sequences from a string
```shell
```nu
> $'(ansi green)(ansi cursor_on)hello' | ansi strip
hello
```
8 changes: 4 additions & 4 deletions commands/docs/any.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ usage: |
## Examples

Check if any row's status is the string 'DOWN'
```shell
```nu
> [[status]; [UP] [DOWN] [UP]] | any {|el| $el.status == DOWN }
true
```

Check that any item is a string
```shell
```nu
> [1 2 3 4] | any {|| ($in | describe) == 'string' }
false
```

Check if any value is equal to twice its own index
```shell
```nu
> [9 8 7 6] | enumerate | any {|i| $i.item == $i.index * 2 }
true
```

Check if any of the values are odd, using a stored closure
```shell
```nu
> let cond = {|e| $e mod 2 == 1 }; [2 4 1 6 8] | any $cond
true
```
14 changes: 7 additions & 7 deletions commands/docs/append.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ usage: |
## Examples

Append one integer to a list
```shell
```nu
> [0 1 2 3] | append 4
╭───┬───╮
│ 0 │ 0 │
Expand All @@ -45,7 +45,7 @@ Append one integer to a list
```

Append a list to an item
```shell
```nu
> 0 | append [1 2 3]
╭───┬───╮
│ 0 │ 0 │
Expand All @@ -57,7 +57,7 @@ Append a list to an item
```

Append a list of string to a string
```shell
```nu
> "a" | append ["b"]
╭───┬───╮
│ 0 │ a │
Expand All @@ -67,7 +67,7 @@ Append a list of string to a string
```

Append three integer items
```shell
```nu
> [0 1] | append [2 3 4]
╭───┬───╮
│ 0 │ 0 │
Expand All @@ -80,7 +80,7 @@ Append three integer items
```

Append integers and strings
```shell
```nu
> [0 1] | append [2 nu 4 shell]
╭───┬───────╮
│ 0 │ 0 │
Expand All @@ -94,7 +94,7 @@ Append integers and strings
```

Append a range of integers to a list
```shell
```nu
> [0 1] | append 2..4
╭───┬───╮
│ 0 │ 0 │
Expand All @@ -110,4 +110,4 @@ Append a range of integers to a list
Be aware that this command 'unwraps' lists passed to it. So, if you pass a variable to it,
and you want the variable's contents to be appended without being unwrapped, it's wise to
pre-emptively wrap the variable in a list, like so: `append [$val]`. This way, `append` will
only unwrap the outer list, and leave the variable's contents untouched.
only unwrap the outer list, and leave the variable's contents untouched.
10 changes: 5 additions & 5 deletions commands/docs/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ usage: |
## Examples

Print the ast of a string
```shell
```nu
> ast 'hello'
```

Print the ast of a pipeline
```shell
```nu
> ast 'ls | where name =~ README'
```

Print the ast of a pipeline with an error
```shell
```nu
> ast 'for x in 1..10 { echo $x '
```

Print the ast of a pipeline with an error, as json, in a nushell table
```shell
```nu
> ast 'for x in 1..10 { echo $x ' --json | get block | from json
```

Print the ast of a pipeline with an error, as json, minified
```shell
```nu
> ast 'for x in 1..10 { echo $x ' -j -m
```
6 changes: 3 additions & 3 deletions commands/docs/bits_and.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ usage: |
## Examples

Apply bits and to two numbers
```shell
```nu
> 2 | bits and 2
2
```

Apply logical and to a list of numbers
```shell
```nu
> [4 3 2] | bits and 2
╭───┬───╮
│ 0 │ 0 │
Expand All @@ -49,4 +49,4 @@ Apply logical and to a list of numbers
```


**Tips:** Command `bits and` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `bits and` was not included in the official binaries by default, you have to build it with `--features=extra` flag
8 changes: 4 additions & 4 deletions commands/docs/bits_not.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ usage: |
## Examples

Apply logical negation to a list of numbers
```shell
```nu
> [4 3 2] | bits not
╭───┬─────────────────╮
│ 0 │ 140737488355323 │
Expand All @@ -44,7 +44,7 @@ Apply logical negation to a list of numbers
```

Apply logical negation to a list of numbers, treat input as 2 bytes number
```shell
```nu
> [4 3 2] | bits not -n '2'
╭───┬───────╮
│ 0 │ 65531 │
Expand All @@ -55,7 +55,7 @@ Apply logical negation to a list of numbers, treat input as 2 bytes number
```

Apply logical negation to a list of numbers, treat input as signed number
```shell
```nu
> [4 3 2] | bits not -s
╭───┬────╮
│ 0 │ -5 │
Expand All @@ -66,4 +66,4 @@ Apply logical negation to a list of numbers, treat input as signed number
```


**Tips:** Command `bits not` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `bits not` was not included in the official binaries by default, you have to build it with `--features=extra` flag
6 changes: 3 additions & 3 deletions commands/docs/bits_or.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ usage: |
## Examples

Apply bits or to two numbers
```shell
```nu
> 2 | bits or 6
6
```

Apply logical or to a list of numbers
```shell
```nu
> [8 3 2] | bits or 2
╭───┬────╮
│ 0 │ 10 │
Expand All @@ -49,4 +49,4 @@ Apply logical or to a list of numbers
```


**Tips:** Command `bits or` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `bits or` was not included in the official binaries by default, you have to build it with `--features=extra` flag
6 changes: 3 additions & 3 deletions commands/docs/bits_rol.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ usage: |
## Examples

Rotate left a number with 2 bits
```shell
```nu
> 17 | bits rol 2
68
```

Rotate left a list of numbers with 2 bits
```shell
```nu
> [5 3 2] | bits rol 2
╭───┬────╮
│ 0 │ 20 │
Expand All @@ -51,4 +51,4 @@ Rotate left a list of numbers with 2 bits
```


**Tips:** Command `bits rol` was not included in the official binaries by default, you have to build it with `--features=extra` flag
**Tips:** Command `bits rol` was not included in the official binaries by default, you have to build it with `--features=extra` flag
Loading

0 comments on commit 014f851

Please sign in to comment.