Skip to content

Commit

Permalink
Update syntax highlighting for some blog docs (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Oct 2, 2023
1 parent 014f851 commit cd05802
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 161 deletions.
34 changes: 17 additions & 17 deletions blog/2022-10-18-nushell-0_70.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ As part of this release, we also publish a set of optional plugins you can insta

![Expanded table](../assets/images/0_70_table_expand.png)

- `--expand`: changes a standard table view; expand the table structure so internally all data will be displayed as inner tables

#### **NOTICE**
The `expand` mode can be considered generally slower than a base table view.
So, if you have a large data set it may be slow.

- `--expand-deep {int}`: set a limit after which table enlargement is stopped
- `--flatten`: an `--expand` view option to return a set of values instead of table for a simple lists
- `--flatten-separator {char}`: a configuration of a separator for `--flatten`
- `--collapse`: changes a standard table view; expand the table structure in a squashed way

#### **NOTICE**
`collapse` mode currently doesn't support width control, therefore if your terminal is not wide enough the table might be broken.
The `collapse` mode can be considered generally slower than a base table view.
So, if you have a large data set it may be slow.
- `--expand`: changes a standard table view; expand the table structure so internally all data will be displayed as inner tables

#### **NOTICE**

The `expand` mode can be considered generally slower than a base table view.
So, if you have a large data set it may be slow.

- `--expand-deep {int}`: set a limit after which table enlargement is stopped
- `--flatten`: an `--expand` view option to return a set of values instead of table for a simple lists
- `--flatten-separator {char}`: a configuration of a separator for `--flatten`
- `--collapse`: changes a standard table view; expand the table structure in a squashed way

#### **NOTICE**

`collapse` mode currently doesn't support width control, therefore if your terminal is not wide enough the table might be broken.
The `collapse` mode can be considered generally slower than a base table view.
So, if you have a large data set it may be slow.

# Breaking changes

Expand Down Expand Up @@ -81,10 +83,8 @@ We're continuing to work on language updates and hope to have more information f
- Kangaxx-0 created [Fix issue 6596](https://github.com/nushell/nushell/pull/6603)
- zhiburt created [WIP/ Checkout to new `tabled`](https://github.com/nushell/nushell/pull/6286)


## Documentation


- WindSoilder created [Add note about subexpression with external commands](https://github.com/nushell/nushell.github.io/pull/641)
- zephaniahong created [Update working_with_lists.md](https://github.com/nushell/nushell.github.io/pull/638), and [Update working_with_lists.md](https://github.com/nushell/nushell.github.io/pull/637), and [Update working_with_strings.md](https://github.com/nushell/nushell.github.io/pull/636)
- HoLLy-HaCKeR created [Fix example variables using `-` in their name](https://github.com/nushell/nushell.github.io/pull/635)
Expand Down
26 changes: 10 additions & 16 deletions blog/2022-11-08-nushell-0.71.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In this release, you can now use the [`++` operator to append lists together](ht

For example, you can combine two lists into a new lists made up of the both lists:

```shell
```nu
> [1, 2] ++ [3, 4]
```

Expand All @@ -40,15 +40,15 @@ _Note: Currently, this operator cannot be used to join two tables. This function

Nushell continues improve quality of the language and shell with a set of consistency improvements in this release. These include:

* More [iterating filter commands](https://github.com/nushell/nushell/pull/6951) now support the `$in` variable consistently (webbedspace)
- More [iterating filter commands](https://github.com/nushell/nushell/pull/6951) now support the `$in` variable consistently (webbedspace)

* Lists [now support `upsert`](https://github.com/nushell/nushell/pull/6932) (fdncred)
- Lists [now support `upsert`](https://github.com/nushell/nushell/pull/6932) (fdncred)

* `merge` can now also [operate on records](https://github.com/nushell/nushell/pull/6919) (webbedspace)
- `merge` can now also [operate on records](https://github.com/nushell/nushell/pull/6919) (webbedspace)

* `str substring` can [take ranges](https://github.com/nushell/nushell/pull/6867) (rgwood)
- `str substring` can [take ranges](https://github.com/nushell/nushell/pull/6867) (rgwood)

* `from` and `to` now [show help info](https://github.com/nushell/nushell/pull/6856) (rgwood)
- `from` and `to` now [show help info](https://github.com/nushell/nushell/pull/6856) (rgwood)

## Right prompts can now be on the last line (nibon7)

Expand Down Expand Up @@ -85,6 +85,7 @@ Unfortunately, in some cases, a well-intended PR does not match the direction Nu
To help focus PRs in the future, we kindly ask potential contributors to first reach out to us before making a substantial change to Nushell, especially if the change will affect user experience.
We updated our [contributing guide](https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md) as well as the PR template to reflect this policy.
To summarize:

1. If you want to make some change to Nushell that is more involved than simple bug-fixing, please go to [Discord](https://discordapp.com/invite/NtAbbGn) or a [GitHub issue](https://github.com/nushell/nushell/issues/new/choose) and chat with some core team members and/or other contributors about it.
2. After getting a green light from the core team, implement the feature, open a pull request (PR) and write a full description of the change.
3. If your PR includes any user-facing features (such as adding a flag to a command), clearly list them in the PR description.
Expand All @@ -99,9 +100,9 @@ We hope the new policy will help us make the PR review process smoother.

We've also recently improved how completions work in Nushell to feel closer to how other shells work. Specifically:

* Completion goes "as far as possible". So, the entire word if there's a unique completion, or else up to the shared prefix of possible completions.
* Removes the quick completion behavior whereby a word was completed automatically as soon as the input came to have a unique completion.
* Tab now completes instead of selecting the next menu item (this can be configured)
- Completion goes "as far as possible". So, the entire word if there's a unique completion, or else up to the shared prefix of possible completions.
- Removes the quick completion behavior whereby a word was completed automatically as soon as the input came to have a unique completion.
- Tab now completes instead of selecting the next menu item (this can be configured)

# Breaking changes

Expand All @@ -119,7 +120,6 @@ We've drafted a version of the [design philosophy for 0.80](https://github.com/n

## Nushell


- jt created [bump to 0.71, use 1.63 toolchain](https://github.com/nushell/nushell/pull/7061), and [Remove unnecessary clone in par-each](https://github.com/nushell/nushell/pull/6995)
- sholderbach created [Pin reedline to `0.14.0` release](https://github.com/nushell/nushell/pull/7050), and [Make the example names unique across workspace](https://github.com/nushell/nushell/pull/7046), and [Update reedline](https://github.com/nushell/nushell/pull/7023), and [Make example binaries proper cargo examples](https://github.com/nushell/nushell/pull/7019), and [Refactor ansi stripping into `nu-util` functions](https://github.com/nushell/nushell/pull/6966), and [Remove inadvertent dep on original `ansi_term`](https://github.com/nushell/nushell/pull/6965), and [Update reedline to latest dev](https://github.com/nushell/nushell/pull/6953), and [Remove unused dependencies](https://github.com/nushell/nushell/pull/6945), and [Move nu-test-support into dev deps on nu-command](https://github.com/nushell/nushell/pull/6940), and [Update `nix` crate to `0.25` and narrow features](https://github.com/nushell/nushell/pull/6924), and [Fix `each while` behavior when printing and maybe in other situations by fusing the iterator](https://github.com/nushell/nushell/pull/6897), and [Wrap `open` parse errors from `from` commands](https://github.com/nushell/nushell/pull/6877), and [Remove unnecessary `#[allow(...)]` annotations](https://github.com/nushell/nushell/pull/6870), and [Reduce required dependencies for diagnostics](https://github.com/nushell/nushell/pull/6648)
- fdncred created [Revert "Fix for escaping backslashes in interpolated strings (fixes #6737)"](https://github.com/nushell/nushell/pull/7038), and [bump rust-toolchain to 1.64](https://github.com/nushell/nushell/pull/7005), and [category tweak](https://github.com/nushell/nushell/pull/6982), and [change str distance to output value::int](https://github.com/nushell/nushell/pull/6963), and [tweak upsert help text](https://github.com/nushell/nushell/pull/6962), and [enable ability to upsert into a list like update](https://github.com/nushell/nushell/pull/6932), and [bump to dev version 0.70.1](https://github.com/nushell/nushell/pull/6814)
Expand Down Expand Up @@ -148,12 +148,10 @@ We've drafted a version of the [design philosophy for 0.80](https://github.com/n

## Extension


- melMass created [fix: ⚡️ add path for arm brew](https://github.com/nushell/vscode-nushell-lang/pull/68)

## Documentation


- kubouch created [Add review process change](https://github.com/nushell/nushell.github.io/pull/664), and [Update Modules and Overlays chapters](https://github.com/nushell/nushell.github.io/pull/612)
- webbedspace created [Fix let-env Path example to be accurate for Windows](https://github.com/nushell/nushell.github.io/pull/663), and [Update types_of_data.md](https://github.com/nushell/nushell.github.io/pull/661), and [Updated working_with_strings.md (closes #640)](https://github.com/nushell/nushell.github.io/pull/660), and [Simplified examples by removing unneeded `echo` calls](https://github.com/nushell/nushell.github.io/pull/657), and [Add categories column to command_reference](https://github.com/nushell/nushell.github.io/pull/646)
- PerBothner created [Document display_output hook](https://github.com/nushell/nushell.github.io/pull/662)
Expand All @@ -165,7 +163,6 @@ We've drafted a version of the [design philosophy for 0.80](https://github.com/n
- kambala-decapitator created [fix description of build-string's second example](https://github.com/nushell/nushell.github.io/pull/649)
- hustcer created [Refresh commands docs for nu v0.70](https://github.com/nushell/nushell.github.io/pull/644)


## Nu scripts

- fdncred created [oh-my-nu-v2 script - a new prompt for 8bit/24bit terminals](https://github.com/nushell/nu_scripts/pull/311), and [tweak no back progress bar example](https://github.com/nushell/nu_scripts/pull/308)
Expand All @@ -175,12 +172,9 @@ We've drafted a version of the [design philosophy for 0.80](https://github.com/n

## Reedline


- sholderbach created [Use `Box::default()` in more places](https://github.com/nushell/reedline/pull/512), and [Prepare the `0.14.0` release](https://github.com/nushell/reedline/pull/511), and [Fix the additional moves of normal mode `hjkl`](https://github.com/nushell/reedline/pull/510), and [Split the main example binary into examples](https://github.com/nushell/reedline/pull/506), and [Update workflow to new actions (alternative)](https://github.com/nushell/reedline/pull/505)
- jcgruenhage created [fix: actually use sqlite-dynlib feature](https://github.com/nushell/reedline/pull/504)
- nibon7 created [show right prompt on indicator line in last line mode](https://github.com/nushell/reedline/pull/501), and [render right prompt on the last line of the left prompt](https://github.com/nushell/reedline/pull/492)
- perlindgren created [Custom validator and prompt code examples](https://github.com/nushell/reedline/pull/500)
- dandavison created [Tab inline completion](https://github.com/nushell/reedline/pull/498)
- CozyPenguin created [change cursor shape depending on edit mode](https://github.com/nushell/reedline/pull/494)


30 changes: 15 additions & 15 deletions blog/2022-11-29-nushell-0.72.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ As part of this release, we also publish a set of optional plugins you can insta

Starting with 0.72, it's now much easier to run a command that might fail and then handle the failure if it happens.

```
```nu
try {
1 / 0
} catch {
Expand All @@ -40,7 +40,7 @@ The `catch` part of the `try/catch` is optional. Without it, the `try` block wil

You can also access the error, if one happens, using a closure syntax:

```
```nu
try {
1 / 0
} catch {|e|
Expand All @@ -61,17 +61,17 @@ This uses an improved expanding data view capability from 0.70.

This release also includes a new way of redirecting the stdout and/or stderr of external commands. This gives easier access to the output streams than was previously possible.

```
```nu
> cat foo.txt out> bar.txt
```

```
```nu
> cat missingfilename.txt err> my_error.txt
```

You can also create a stream built from the above, allowing one stream to empty and then be followed by the other stream:

```
```nu
> git status out+err> git_status.txt
```

Expand All @@ -81,7 +81,7 @@ We have now split closures and blocks into two separate value types. A closure c

An example closure:

```
```nu
ls | each {|it| print $it.name }
```

Expand All @@ -91,7 +91,7 @@ A block is much simpler and is used as the bottom of commands like `if` and loop

An example block:

```
```nu
if true {
print "hello!"
}
Expand All @@ -103,15 +103,15 @@ Blocks don't close over (or capture) variables, don't have parameters, and can't

Starting in this release, you can create local mutable variables. You can create mutable variables using the `mut` keyword:

```
```nu
mut x = 1
$x = $x + 100
print $x
```

A mutable variable can only live and change in the closure in which it's created. Blocks, however, have access to the mutable variables in the parent closure. For example, mutating a variable inside of the block used in an `if` call is valid:

```
```nu
mut x = 1
if true {
$x += 1000
Expand All @@ -125,15 +125,15 @@ The 0.72 release also includes a few new looping commands: `loop` and `while`.

The `loop` command runs a block forever:

```
```nu
loop {
print "hit ctrl-c to break out of this example"
}
```

The `while` command will run its block as long as a condition is met:

```
```nu
mut x = 0
while $x < 10 {
print $x
Expand All @@ -149,7 +149,7 @@ Loops can now also use the `break` and `continue` feature common in many program

The 0.72 release also includes the ability to return early from a closure or command.

```
```nu
def foo [x] {
if $x > 10 {
return 1000
Expand All @@ -172,7 +172,7 @@ To continue using dataframe commands, you can build Nu from source using the `da

A common pattern in using overlays is shadowing an existing environment variable, such as PROMPT_COMMAND. However, `overlay use` would keep loading the value from the first activation. It is best explained with an example. Assume the following module:

```
```nu
module prompt {
export-env {
let-env PROMPT_COMMAND = (date now | into string)
Expand Down Expand Up @@ -230,7 +230,7 @@ The changes are:

The new grouped options look like this:

```sh
```nu
ls: {
use_ls_colors: true # use the LS_COLORS environment variable to colorize output
clickable_links: true # enable or disable clickable links. Your terminal has to support links.
Expand Down Expand Up @@ -274,7 +274,7 @@ The new grouped options look like this:

To output your existing options in the above format (that could be pasted into your config.nu file before you delete the old options), run this code in your copy of Nushell:

```sh
```nu
$env.config | do { { ls: { use_ls_colors: $in.use_ls_colors clickable_links: $in.show_clickable_links_in_ls } rm: { always_trash: $in.rm_always_trash } cd: { abbreviations: $in.cd_with_abbreviations } table: { mode: $in.table_mode index_mode: $in.table_index_mode trim: $in.table_trim } history: { max_size: $in.max_history_size sync_on_enter: $in.sync_history_on_enter file_format: $in.history_file_format } completions: { case_sensitive: $in.case_sensitive_completions quick: $in.quick_completions partial: $in.partial_completions algorithm:$in.completion_algorithm external: { enable: $in.enable_external_completion max_results: $in.max_external_completion_results completer:$in.external_completer } } } } | to nuon | str substring 1..-1
```

Expand Down
22 changes: 11 additions & 11 deletions blog/2022-12-20-nushell-0.73.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The goal is to remove the `math eval` command that operates on strings instead o
- `math log`
- `math ln`

```sh
```nu
〉math pi | math cos
-1
〉math e | math ln
Expand All @@ -83,13 +83,13 @@ The goal is to remove the `math eval` command that operates on strings instead o

`any`, `all`, `skip until`, `skip while`, `take until`, and `take while` now accept a closure instead of a row condition. For example

```sh
```nu
[[status]; [UP] [UP]] | all status == UP
```

becomes

```sh
```nu
[[status]; [UP] [UP]] | all {|el| $el.status == UP }
```

Expand All @@ -99,19 +99,19 @@ This makes them slightly more verbose but it is a part of an effort to refactor

We found the `-b` flag of `where` quite confusing and decided to remove it in favor of a new `filter` command. Both `filter` and `where` have similar functionality but `where` now only accepts a row condition and `filter` accepts a closure. Before:

```sh
```nu
[{a: 1} {a: 2}] | where -b {|x| $x.a > 1}
```

After:

```sh
```nu
[{a: 1} {a: 2}] | filter {|x| $x.a > 1}
```

Why is it useful to have two commands doing the same thing? Because with the `filter` command, you can store the closure in a variable:

```sh
```nu
let cond = {|x| $x.a > 1}
[{a: 1} {a: 2}] | filter $cond
```
Expand All @@ -123,7 +123,7 @@ On the other hand, `where` is more concise (`[{a: 1} {a: 2}] | where a > 1`) but
To complement `uniq` which can identify unique or duplicated values in a collection or report the number of occurrences for a particular entry, we now have `uniq-by`.
It supports filtering a table by entries appearing in a particular column.

```sh
```nu
〉 [[fruit day]; [apple monday] [apple friday] [Apple friday] [apple monday] [pear monday] [orange tuesday]] | uniq-by fruit
╭───┬────────┬─────────╮
│ # │ fruit │ day │
Expand All @@ -139,7 +139,7 @@ It supports filtering a table by entries appearing in a particular column.

If a variable has been defined as mutable using the recently-added `mut` keyword, you can now deeply mutate its inner values using `=`.

```sh
```nu
〉 mut a = { b: 1 }
〉 $a.b = 2
〉 $a.c = 3
Expand All @@ -149,7 +149,7 @@ If a variable has been defined as mutable using the recently-added `mut` keyword

This syntax enhancement was added primarily to make modifying `$env.config` during a normal session much easier. Now, `$env.config` is considered inherently mutable. You can change a single config value like so:

```sh
```nu
$env.config.table.mode = compact_double
```

Expand All @@ -161,7 +161,7 @@ The `color_config` config record has new functionality: instead of specifying a

Here are some examples.

```sh
```nu
filesize: {|e|
if $e == 0b { 'dark_gray'
} else if $e < 1mb { 'cyan_bold'
Expand All @@ -171,7 +171,7 @@ filesize: {|e|

This causes all filesize values to be colored using `dark_gray` if they equal `0b`, `cyan_bold` if they are less than `1mb`, and `blue_bold` otherwise. This means that, in `ls` output, empty files can be more easily distinguished from non-empty ones.

```sh
```nu
bool: { if $in { 'light_cyan' } else { 'light_gray' } }
```

Expand Down
Loading

0 comments on commit cd05802

Please sign in to comment.