Skip to content

Commit

Permalink
Update syntax highlighting for Nu (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Oct 2, 2023
1 parent cd05802 commit 0aecd6f
Show file tree
Hide file tree
Showing 37 changed files with 192 additions and 192 deletions.
2 changes: 1 addition & 1 deletion blog/2021-06-22-nushell_0_33.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Behind the scenes, we've also refactored completions into their own crate, so th

Sometimes, when you're working on a pipeline, you want to refer to values coming in using an xargs style. With 0.33, we've introduced a new built-in variable called `$in`. The `$in` variable will collect the pipeline into a value for you, allowing you to access the whole stream as a parameter.

```shell
```nu
> echo 1 2 3 | $in.1 * $in.2
6
```
Expand Down
4 changes: 2 additions & 2 deletions blog/2022-09-06-nushell-0_68.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ This change is intended to test it with a larger audience to decide which one we

This example shows that the `edit distance` is one edit step difference using the Levenshtein algorithm.

```sh
```nu
> 'nushell' | str distance 'nutshell'
╭──────────┬───╮
│ distance │ 1 │
Expand All @@ -187,7 +187,7 @@ We'd eventually like to add more similarity comparison functionality to nushell.

The new parameter on `into duration` `--convert` allows you to convert from string durations into named durations.

```sh
```nu
> '7min' | into duration --convert sec
420 sec
```
Expand Down
4 changes: 2 additions & 2 deletions blog/2023-02-21-nushell_0_76.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ _Note: There are known limitations that the profiler can't run. For example, it

- [`timeit`](https://github.com/nushell/nushell/pull/8018) (formerly known as benchmark, same functionality)

```bash
```nu
〉timeit { ls | sort-by name type -i | get name }
2ms 509µs 900ns
```
Expand All @@ -69,7 +69,7 @@ _Note: There are known limitations that the profiler can't run. For example, it

- [`view source`](https://github.com/nushell/nushell/pull/7989) (formerly known as `view-source`, same functionality)

```bash
```nu
〉def my-cmd [arg] { echo $arg }
〉my-cmd hi
hi
Expand Down
2 changes: 1 addition & 1 deletion blog/2023-03-14-nushell_0_77.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Let's take the `merge` command as an example!

Before the change, the output of `help merge` would give

```bash
```nu
Examples:
Add an 'index' column to the input table
> [a b c] | wrap name | merge ( [1 2 3] | wrap index )
Expand Down
2 changes: 1 addition & 1 deletion blog/2023-09-19-nushell_0_85_0.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Please use `into float` instead of `into decimal` and `random float` instead of

After the type returned by `describe` has been `float` for a while, we now also change which type name is allowed when specifying command argument or input/output types.

```sh
```nu
# Argument with a specfic type
def foo [bar: float] {}
# Command taking only floating point input from the pipeline and returning the same type.
Expand Down
2 changes: 1 addition & 1 deletion book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def my-ls [] { ls }

We can use the output from this command just as we would [`ls`](/commands/docs/ls.md).

```
```nu
> my-ls | get name
───┬───────────────────────
0 │ myscript.nu
Expand Down
2 changes: 1 addition & 1 deletion book/working_with_tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Let's add a third table:

We could join all three tables together like this:

```
```nu
> $first | merge $second | merge $third
───┬───┬───┬───┬───┬───┬───
# │ a │ b │ c │ d │ e │ f
Expand Down
2 changes: 1 addition & 1 deletion de/book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def my-ls [] { ls }

Die Ausgabe dieses Befehls, kann identisch zur Ausgabe von `ls` verwendet werden.

```
```nu
> my-ls | get name
───┬───────────────────────
0 │ myscript.nu
Expand Down
10 changes: 5 additions & 5 deletions de/book/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Mathematische Operationen werden in der folgenden Reihenfolge ausgewertet (von d

- Klammern (`()`)
- Potenzieren (`**`)
- Multiplizieren (`*`), Dividieren (`/`), Abrundungs Division (`//`), und Modulo (`mod`)
- Multiplizieren (`*`), Dividieren (`/`), Abrundungs Division (`//`), und Modulo (`mod`)
- Addieren (`+`) and Subtrahieren (`-`)
- Bit Shiften (`bit-shl`, `bit-shr`)
- Vergleich Operations (`==`, `!=`, `<`, `>`, `<=`, `>=`), Mitglieds Tests (`in`, `not-in`, `starts-with`, `ends-with`), regex Übereinstimmungen (`=~`, `!~`), und Listen anfügen (`++`)
Expand Down Expand Up @@ -91,7 +91,7 @@ Fundierte Kenntnisse in Regluären Ausdrücke werdne dafür nicht benötigt - es

Zum Beispiel:

```bash
```nu
foobarbaz =~ bar # gibt true zurück
foobarbaz !~ bar # gibt false zurück
ls | where name =~ ^nu # Gibt alle Dateien zurück, deren Namen mit "nu" beginnen.
Expand All @@ -105,19 +105,19 @@ Operatoren beachten grundsätzlich die Gross- Kleinschreibung bei Textoperatione

1. Beim regulären Ausdruck Operator, kann die `(?i)` Modifikation angewendet werden:

```bash
```nu
"FOO" =~ "foo" # gibt false zurück
"FOO" =~ "(?i)foo" # gibt true zurück
```

2. Verwenden des `--insensitive` Parameters für den [`str contains`](/commands/docs/str_contains.md) Befehl:

```bash
```nu
"FOO" | str contains --insensitive "foo"
```

3. Konvertieren von allen Zeichen in einem Text zu Kleinbuchstaben mittels [`str downcase`](/commands/docs/str_downcase.md) vor einem Vergleich:

```bash
```nu
("FOO" | str downcase) == ("Foo" | str downcase)
```
2 changes: 1 addition & 1 deletion de/book/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Argumente werden an ein Skript übergeben indem sie nach dem Skriptnamen angefü

Zum Beispiel:

```bash
```nu
# myscript.nu
def main [x: int] {
Expand Down
30 changes: 15 additions & 15 deletions de/book/working_with_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Zum Beispiel, `[foo bar baz]` oder `[foo, bar, baz]`,
Mit den zwei Befehlen `update` und `insert` können Listen in einer Pipeline verändert werden,
zum Beispiel fügt folgende Zeile den Wert `10` in der Mitte, also an Stelle 2 ein.

```bash
```nu
> [1, 2, 3, 4] | insert 2 10
# [1, 2, 10, 3, 4]
```

Mit dem Befehl `update` ersetzen wir hingegen das 2. Element mit dem Wert `10`.

```bash
```nu
> [1, 2, 3, 4] | update 1 10
# [1, 10, 3, 4]
```
Expand All @@ -29,7 +29,7 @@ Diese fügen Werte am Anfang einer Liste oder am Ende ein.

Zum Beispiel:

```bash
```nu
let colors = [yellow green]
let colors = ($colors | prepend red)
let colors = ($colors | append purple)
Expand All @@ -43,7 +43,7 @@ mit Nu-Code folgt, der auf jedes Element der Liste angewendet wird. Der Block Pa
entspricht normalerweise dem Element der Liste, was jedoch mit dem `--numbered` (`-n`) Flag geändert werden kann in die zwei
Parameter `index` und `item`. zum Beispiel:

```bash
```nu
let names = [Mark Tami Amanda Jeremy]
$names | each { |it| $"Hello, ($it)!" }
# Outputs "Hello, Mark!" and three more similar lines.
Expand All @@ -55,14 +55,14 @@ $names | enumerate | each { |it| $"($it.index + 1) - ($it.item)" }
Der [`where`](/commands/docs/where.md) Befehl kann verwendet werden um einen Filter auf eine Liste anzuwenden.
Das folgende Beispiel gibt alle Farben zurück, deren Namen auf "e" enden.

```bash
```nu
let colors = [red orange yellow green blue purple]
echo $colors | where ($it | str ends-with 'e')
```

In diesem Beispiel werden nur Werte behalten, die höher als `7` sind.

```bash
```nu
# The block passed to where must evaluate to a boolean.
# This outputs the list [orange blue purple].
Expand All @@ -77,7 +77,7 @@ wird das `--fold` (`-f`) Flag gesetzt. Um den Iterator `it` zu ändern nach `ind
das `--numbered` (`-n`) Flag verwendet.
Zum Beispiel:

```bash
```nu
let scores = [3 8 4]
echo "total =" ($scores | reduce { |it, acc| $acc + $it }) # 15
Expand All @@ -93,14 +93,14 @@ echo $scores | reduce -n { |it, acc| $acc.item + $it.index * $it.item } # 3 + 1*
Um auf ein Element einer Liste zuzugreifen, wird `$name.index` verwendet, wobei in der `$name` Variablen eine Liste enthalten sein muss.
Zum Beispiel kann in folgender Liste das 2. Element mit `$names.1` verwendet werden.

```bash
```nu
let names = [Mark Tami Amanda Jeremy]
$names.1 # gives Tami
```

Wenn der Index in einer Variablen wie `$index` enthalten ist, kann dieser mit dem `get` Befehl extrahiert werden.

```bash
```nu
let names = [Mark Tami Amanda Jeremy]
let index = 1
$names | get $index # gives Tami
Expand All @@ -112,7 +112,7 @@ Zum Beispiel, `[red green blue] | length` ergibt `3`.
Der [`is-empty`](/commands/docs/is-empty.md) Befehl ermittelt, ob ein String, eine Liste oder eine Tabelle leer ist.
Mit einer Liste wird er so verwendet:

```bash
```nu
let colors = [red green blue]
$colors | is-empty # false
Expand All @@ -123,7 +123,7 @@ $colors | is-empty # true
Der `in` und `not-in` Operator wird verwendet, um zu testen, ob ein Wert in einer Liste vorhanden ist oder nicht.
Zum Beispiel:

```bash
```nu
let colors = [red green blue]
'blue' in $colors # true
'yellow' in $colors # false
Expand All @@ -133,7 +133,7 @@ let colors = [red green blue]
Der [`any`](/commands/docs/any.md) Befehl ermittelt, ob irgend ein Element der Liste einer Bedingung entspricht.
Zum Beispiel:

```bash
```nu
# Do any color names end with "e"?
$colors | any {|it| $it | str ends-with "e" } # true
Expand All @@ -150,7 +150,7 @@ $scores | any {|it| $it mod 2 == 1 } # true
Der [`all`](/commands/docs/all.md) Befehl wiederum ermittelt, ob jedes Element der Liste einer Bedingung entspricht.
Zum Beispiel:

```bash
```nu
# Do all color names end with "e"?
$colors | all {|it| $it | str ends-with "e" } # false
Expand All @@ -171,7 +171,7 @@ indem eine verschachtelte Liste in die Top-Level Liste integriert werden.
Dies kann mehrere Male aufgerufen werden, um verschachtelte Listen jeglicher Tiefe zu integrieren.
Zum Beispiel:

```bash
```nu
echo [1 [2 3] 4 [5 6]] | flatten # [1 2 3 4 5 6]
echo [[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]
Expand All @@ -180,7 +180,7 @@ echo [[1 2] [3 [4 5 [6 7 8]]]] | flatten | flatten | flatten # [1 2 3 4 5 6 7 8]
Der [`wrap`](/commands/docs/wrap.md) Befehl konvertiert eine Liste in eine Tabelle.
Jedes Listen-Element wird in eine eigene Zeile mit einer einzigen Spalte überführt.

```bash
```nu
let zones = [UTC CET Europe/Moscow Asia/Yekaterinburg]
# Show world clock for selected time zones
Expand Down
2 changes: 1 addition & 1 deletion pt-BR/book/instalacao.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ nushell> cargo build --workspace --features=stable; cargo run --features=stable

Você também pode fazer o build e rodar o Nu em modo release:

```bash
```nu
nushell> cargo build --release --workspace --features=stable; cargo run --release --features=stable
```

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/3rdpartyprompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $env.PROMPT_INDICATOR = $"(ansi y)$> (ansi reset)"

下面是一个关于 Starship 的配置示例:

```bash
```nu
$env.STARSHIP_SHELL = "nu"
def create_left_prompt [] {
Expand Down
4 changes: 2 additions & 2 deletions zh-CN/book/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Nushell 中的别名提供了一种简单的文本替换方式,这允许你为

例如,让我们创建一个名为 `ll` 的别名,它将展开为 `ls -l`

```bash
```nu
> alias ll = ls -l
```

我们可以通过别名来调用它:

```bash
```nu
> ll
```

Expand Down
2 changes: 1 addition & 1 deletion zh-CN/book/coming_from_bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
如果你是来自 Windows 上的`Git Bash`用户,那么你习惯的外部命令(bash、grep 等)在`nu`中默认是不可用的(除非你在 Windows 路径环境变量中明确包含了它们)。
要使这些命令在`nu`中可用,请在你的`config.nu`中添加以下一行,用`append``prepend`

```bash
```nu
$env.Path = ($env.Path | prepend 'C:\Program Files\Git\usr\bin')
```

Expand Down
12 changes: 6 additions & 6 deletions zh-CN/book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ _(你可以把 Nushell 的配置加载顺序想象成在启动时执行两行 [R

Nushell 的主要设置是以记录的形式保存在 `config` 环境变量中。这个记录可以用以下方式创建:

```bash
```nu
$env.config = {
...
}
```

你也可以隐藏(shadow)`$env.config`并更新它:

```bash
```nu
$env.config = ($env.config | upsert <field name> <field value>)
```

Expand All @@ -35,7 +35,7 @@ $env.config = ($env.config | upsert <field name> <field value>)

你可以在 Nushell 会话期间使用 `$env.<var> = <val>``env.nu` 文件中设置环境变量。比如:

```bash
```nu
$env.FOO = 'BAR'
```

Expand Down Expand Up @@ -72,15 +72,15 @@ Nushell 遵循如下的规则来匹配编辑器:

你可以通过在另一个 Shell(如 Bash)中运行 Nu 来建立完整的环境变量集。一旦你进入 Nu,你可以运行这样的命令:

```bash
```nu
$env | reject config | transpose key val | each {|r| echo $"$env.($r.key) = '($r.val)'"} | str join (char nl)
```

这将打印出 `$env.<var> = <val>` 行,每个环境变量一行包含其设置。您可能不需要所有这些变量,例如,`PS1` 变量是 `bash` 特有的。

接下来,在一些发行版上,你还需要确保 Nu 在`/etc/shells`列表中:

```bash
```nu
> cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
Expand Down Expand Up @@ -108,7 +108,7 @@ $env | reject config | transpose key val | each {|r| echo $"$env.($r.key) = '($r
由于 Nushell 有自己的[`open`](/commands/docs/open.md)命令,它有不同的语义并隐藏了`/usr/bin/open`,这样某些工具在试图使用它时将出错。
一个解决这个问题的方法是为 Nushell 的`open`定义一个自定义命令,并在你的`config.nu`文件中为系统的`open`创建一个别名,像这样:

```bash
```nu
def nuopen [arg, --raw (-r)] { if $raw { open -r $arg } else { open $arg } }
alias open = ^open
```
Expand Down

0 comments on commit 0aecd6f

Please sign in to comment.