Skip to content

Commit

Permalink
Merge pull request #256 from rgwood/nu-book-grammar
Browse files Browse the repository at this point in the history
Nu book: grammar + spelling pass
  • Loading branch information
sophiajt committed Mar 6, 2022
2 parents 311c379 + 69b26c6 commit d9839a5
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 93 deletions.
8 changes: 4 additions & 4 deletions book/3rdpartyprompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ nerdfonts are not required but they make the presentation much better.

[repo](https://github.com/JanDeDobbeleer/oh-my-posh)

If you like [oh-my-posh](https://ohmyposh.dev/), you can use oh-my-posh with nushell with few steps. It's works great with nushell. There is how to setup oh-my-posh with nushell:
If you like [oh-my-posh](https://ohmyposh.dev/), you can use oh-my-posh with Nushell with a few steps. It works great with Nushell. How to setup oh-my-posh with Nushell:

1. Install Oh My Posh and download oh-my-posh's themes following [guide](https://ohmyposh.dev/docs/linux#installation).
2. Download and Install a [nerd font](https://github.com/ryanoasis/nerd-fonts).
2. Download and install a [nerd font](https://github.com/ryanoasis/nerd-fonts).
3. Set the PROMPT_COMMAND in ~/.config/nushell/config.nu, change `M365Princess.omp.json` to whatever you like [Themes demo](https://ohmyposh.dev/docs/themes).

```shell
Expand All @@ -35,8 +35,8 @@ If you like [oh-my-posh](https://ohmyposh.dev/), you can use oh-my-posh with nus
3. Set the starship shell environment variable to `nu` by running this commend `let-env STARSHIP_SHELL = "nu"`
4. If you want the default ticking clock with date & time on the right prompt execut this command `hide PROMPT_COMMAND_RIGHT`
5. If you don't want the default indicator, you can run this command `let-env PROMPT_INDICATOR = " "`
6. Set starship as your left prompt with this command `let-env PROMPT_COMMAND = { starship prompt --cmd-duration $env.CMD_DURATION_MS --status $env.LAST_EXIT_CODE | str trim }`. Note that you may not have to use `str trim` in the nushell prompt if you disable starship's default newline setting with this entry in the starship.toml file `add_newline = false`. There have been reports that this might not play nice with nushell prompts. We're still testing.
7. Since nushell supports a right prompt you can also play around with starship's ability to set a right prompt. Setting the right prompt in nushell is identical to setting the left prompt however you use `PROMPT_COMMAND_RIGHT`.
6. Set starship as your left prompt with this command `let-env PROMPT_COMMAND = { starship prompt --cmd-duration $env.CMD_DURATION_MS --status $env.LAST_EXIT_CODE | str trim }`. Note that you may not have to use `str trim` in the Nushell prompt if you disable starship's default newline setting with this entry in the starship.toml file `add_newline = false`. There have been reports that this might not play nice with Nushell prompts. We're still testing.
7. Since Nushell supports a right prompt you can also play around with starship's ability to set a right prompt. Setting the right prompt in Nushell is identical to setting the left prompt however you use `PROMPT_COMMAND_RIGHT`.
## Purs
Expand Down
14 changes: 7 additions & 7 deletions book/coloring_and_theming.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Coloring and Theming in Nushell

There are a few main parts that nushell allows you to change the color. All of these can be set in the `config.nu` configuration file. If you see the hash/hashtag/pound mark `#` in the config file it means the text after it is commented out.
Many parts of Nushell's interface can have their color customized. All of these can be set in the `config.nu` configuration file. If you see the hash/hashtag/pound mark `#` in the config file it means the text after it is commented out.

1. table borders
2. primitive values
Expand All @@ -12,7 +12,7 @@ There are a few main parts that nushell allows you to change the color. All of t

---

Table borders are controlled by the `table_mode` setting in the `config.nu`. Here is an example:
Table borders are controlled by the `table_mode` setting in `config.nu`. Here is an example:

```shell
> let $config = {
Expand Down Expand Up @@ -200,11 +200,11 @@ Here are the current options for `table_mode`:

---

The "#hex" format is one way you typically see colors represented. It's simply the `#` character followed by 6 characters. The first two are for `red`, the second two are for `green`, and the third two are for `blue`. It's important that this string be surrounded in quotes, otherwise nushell thinks it's a commented out string.
The "#hex" format is one way you typically see colors represented. It's simply the `#` character followed by 6 characters. The first two are for `red`, the second two are for `green`, and the third two are for `blue`. It's important that this string be surrounded in quotes, otherwise Nushell thinks it's a commented out string.

Example: The primary `red` color is `"#ff0000"` or `"#FF0000"`. Upper and lower case in letters shouldn't make a difference.

This `"#hex"` format allows us to specify 24-bit truecolor tones to different parts of nushell.
This `"#hex"` format allows us to specify 24-bit truecolor tones to different parts of Nushell.

## `full "#hex"` format

Expand Down Expand Up @@ -314,7 +314,7 @@ Here's another small example using multiple color syntaxes with some comments.
## `Shape` values
As mentioned above, `shape` is a term used to indicate the sytax coloring.
As mentioned above, `shape` is a term used to indicate the syntax coloring.
Here's the current list of flat shapes.
Expand Down Expand Up @@ -358,7 +358,7 @@ Here's a small example of how to apply color to these items. Anything not specif
## `Prompt` configuration and coloring
The nushell prompt is configurable through these environment variables settings.
The Nushell prompt is configurable through these environment variables:
- `PROMPT_COMMAND`: Code to execute for setting up the prompt (block)
- `PROMPT_COMMAND_RIGHT`: Code to execute for setting up the _RIGHT_ prompt (block) (see oh-my.nu in nu_scripts)
Expand Down Expand Up @@ -400,7 +400,7 @@ Theming combines all the coloring above. Here's a quick example of one we put to
The key to making theming work is to make sure you specify all themes and colors you're going to use in the `config.nu` file _before_ you declare the `let config = ` line.
```
# lets define some colors
# let's define some colors
let base00 = "#181818" # Default Background
let base01 = "#282828" # Lighter Background (Used for status bars, line number and folding marks)
Expand Down
10 changes: 5 additions & 5 deletions book/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Nushell Configuration with `config.nu`

Nushell uses a configuration system that loads a nushell script file at launch time. That configuration file is called the Nushell `config.nu` file. The path to the configuration file can be found by calling `echo $nu.config-path`. It's a source file that runs, each step adding definitions, environment variables, and more to the global namespace.
Nushell uses a configuration system that loads+runs a Nushell script file at launch time. That configuration file is called the `config.nu` file, and the path to it can be found by calling `echo $nu.config-path`. `config.nu` can add definitions, environment variables, and more to the global namespace.

An example of the nushell `config.nu` can be found in our repo [here](https://github.com/nushell/nushell/blob/main/src/default_config.nu).
An example `config.nu` file can be found in our repo [here](https://github.com/nushell/nushell/blob/main/src/default_config.nu).

### Configuring `$config`

Expand All @@ -24,7 +24,7 @@ let $config = ($config | update <field name> <field value>)

### Environment

You can update the environment using `let-env` calls inside of the `config.nu` file. There are some important ones to look at which doing Nushell-specific settings:
You can set environment variables using `let-env` calls inside the `config.nu` file. These are some important variables to look at for Nushell-specific settings:

- `LS_COLORS`: Sets up colors per file type in ls
- `PROMPT_COMMAND`: Code to execute for setting up the prompt (block or string)
Expand All @@ -48,7 +48,7 @@ You can build the full set of environment variables by running Nu inside of anot
> env | each { echo $"let-env ($it.name) = '($it.raw)'" } | str collect (char nl)
```

This will print out a `let-env` lines, one for each environment variable along with its setting.
This will print out `let-env` lines, one for each environment variable along with its setting.

Next, on some distros you'll also need to ensure Nu is in the /etc/shells list:

Expand All @@ -69,7 +69,7 @@ With this, you should be able to `chsh` and set Nu to be your login shell. After
### macOS: Keeping `/usr/bin/open` as `open`

Some tools (e.g. Emacs) rely on an `open` command to open files on Mac.
As nushell has its own `open` command which has different semantics and shadows `/usr/bin/open`, these tools will error out when trying to use it.
As Nushell has its own `open` command which has different semantics and shadows `/usr/bin/open`, these tools will error out when trying to use it.
One way to work around this is to define `alias`es in your `config.nu` file like this:

```
Expand Down
2 changes: 1 addition & 1 deletion book/creating_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Using the [metadata](metadata.md) information, you can create your own custom er
* The title of the error
* The label of error message, which includes both the text of the label and the span to underline

You can use the `error make` command to create your own error messages. For example, let's say you had your own command called `my-command` and you wanted to give an error back to the caller about something wrong the the parameter that was passed in.
You can use the `error make` command to create your own error messages. For example, let's say you had your own command called `my-command` and you wanted to give an error back to the caller about something wrong with a parameter that was passed in.

First, you can take the span of where the argument is coming from:

Expand Down
4 changes: 2 additions & 2 deletions book/custom_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def greet [name] {
}
```

In this definition, we define the `greet` command, which takes a single parameter `name`. Following this parameter is the block that represents what will happen with the custom command runs. When called, the custom command will set the value passed for `name` as the `$name` variable, which will be available to the block.
In this definition, we define the `greet` command, which takes a single parameter `name`. Following this parameter is the block that represents what will happen when the custom command runs. When called, the custom command will set the value passed for `name` as the `$name` variable, which will be available to the block.

To run the above, we can call it like we would call built-in commands:

Expand All @@ -31,7 +31,7 @@ As we do, we also get output just as we would with built-in commands:

## Command names

In Nushell, a command name a string of characters or a quoted string. Here are some examples of valid command names: `greet`, `get-size`, `mycommand123`, `"mycommand"`, `😊`, and `123`.
In Nushell, a command name is a string of characters or a quoted string. Here are some examples of valid command names: `greet`, `get-size`, `mycommand123`, `"mycommand"`, `😊`, and `123`.

_Note: It's common practice in Nushell to separate the words of the command with `-` for better readability._ For example `get-size` instead of `getsize` or `get_size`.

Expand Down

0 comments on commit d9839a5

Please sign in to comment.