Home Explore Blog CI



nushell

2nd chunk of `blog/2019-11-05-nushell-0_5_0.md`
c9e030c87826054f7c225b2df2c7e16e458c38497933bba10000000100000a2a
 2 │ /usr/sbin
 3 │ /usr/bin
 4 │ /sbin
 5 │ /bin
 6 │ /usr/games
 7 │ /usr/local/games
 8 │ /snap/bin
━━━┷━━━━━━━━━━━━━━━━━━
```

We've added two new commands: `prepend` for adding items to the start of a table and `append` for adding items to the end of a table. With these commands, we can now query out the path, update it, and save it back.

```shell
> echo $nu:path | prepend "/my/new/directory" | config --set_into path
```

Version 0.7.2 and later:

```shell
> echo $nu.path | prepend "/my/new/directory" | config set_into path
```

## Adding variables to your environment

You can use a similar set of steps to add new variables, or change existing variables, in your environment.

```shell
> echo $nu:env | insert GREETING hello_world | config --set_into env
```

Version 0.7.2 and later:

```shell
> echo $nu.env | insert GREETING hello_world | config set_into env
```

_Note: the previous `add` command of previous releases has been renamed `insert` to remove confusion with mathematical functions._

# On-going improvements

We're continuing to improve the commands we currently ship as part of Nu. Here are a few you might find helpful:

## Substrings (Flare576)

The `str` command now supports being able to retrieve a substring from the strings given, so you could return, for example, the first 5 characters and stop after that.

```shell
> ls | get name
━━━━┯━━━━━━━━━━━━━━━━━━━━
 #  │ <value>
────┼────────────────────
  0 │ target
  1 │ CODE_OF_CONDUCT.md
  2 │ .cargo
  3 │ src
  4 │ features.toml
  5 │ rustfmt.toml
```

```shell
> ls | get name | str --substring "0,3"
━━━━┯━━━━━━━━━
 #  │ <value>
────┼─────────
  0 │ tar
  1 │ COD
  2 │ .ca
  3 │ src
  4 │ fea
  5 │ rus
```

## Recycling (jdvr)

Ever wish you could `rm` things, but not forever? You can now tell `rm` to send items to your platform's recycle bin rather than deleting them forever. As with our other commands, this works across all the platforms that Nu supports.

```shell
> rm myfile.txt --trash
```

## Parameter descriptions (sophiajt)

We're also continuing to improve the built-in help system. New in this release are descriptions for the flags and parameters that the command uses. For example, here's a look at what the help for `rm` now looks like:

```shell
> help rm
Remove a file

Usage:
  > rm <path> {flags}

parameters:
  <path> the file path to remove

Title: Nushell 0.5.0: Environment Variables, Substrings, Recycling, and Parameter Descriptions
Summary
This section covers improvements in Nushell 0.5.0. It includes how to add variables to your environment, substring support in the `str` command, a recycling feature for the `rm` command to send items to the recycle bin instead of deleting them permanently, and improved help system with descriptions for command flags and parameters.