Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions book/coming_from_bash.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Coming from Bash

If you're coming from `Git Bash` on Windows, then the external commands you're used to (bash, grep, etc) will not be available in `nu` by default (unless you had explicitly made them available in the Windows Path environment variable).
To make these commands available in `nu` as well, add the following line to your `config.nu` with either `append` or `prepend`.
::: tip
If you're coming from `Git Bash` on Windows, then the external commands you're used to (e.g, `ln`, `grep`, `vi`, etc) will not be available in Nushell by default unless you have already explicitly made them available in the Windows Path environment variable.
To make these commands available in Nushell as well, add the following line to your `config.nu` with either `append` or `prepend`.

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

## Command equivalents:

| Bash | Nu | Task |
| ------------------------------------ | ------------------------------------------------------------- | ----------------------------------------------------------------- |
Expand Down Expand Up @@ -69,3 +73,30 @@ $env.Path = ($env.Path | prepend 'C:\Program Files\Git\usr\bin')
| `pwd` | `$env.PWD` | Display the current directory |
| `read var` | `let var = input` | Get input from the user |

## History Substitutions and Default Keybindings:

| Bash | Nu | Task |
| ------------------------------------ | ------------------------------------------------------------- | ----------------------------------------------------------------- |
| `!!` | `!!` | Insert last command-line from history |
| `!$` | `!$` | Insert last spatially separated token from history |
| `!<n>` (e.g., `!5`) | `!<n>` | Insert \<n\>th command from the beginning of the history |
| | | Tip: `history \| enumerate \| last 10` to show recent positions |
| `!<-n>` (e.g., `!-5`) | `!<-n>` | Insert \<n\>th command from the end of the history |
| `!<string>` (e.g., `!ls`) | `!<string>` | Insert the most recent history item that begins with the string |
| <kbd>Ctrl/Cmd</kbd>+<kbd>R</kbd> | <kbd>Ctrl/Cmd</kbd>+<kbd>R</kbd> | Reverse history search |
| (Emacs Mode) <kbd>Ctrl</kbd>+<kbd>X</kbd><kbd>Ctrl</kbd>+<kbd>E</kbd> | <kbd>Ctrl/Cmd</kbd>+<kbd>O</kbd> | Edit the command-line in the editor defined by `$env.EDITOR` |
| (Vi Command Mode) <kbd>V</kbd> | <kbd>Ctrl/Cmd</kbd>+<kbd>O</kbd> | Edit the command-line in the editor defined by `$env.EDITOR` |

Most common Emacs-mode and Vi-mode keybindings are also available. See the [Reedline Chapter](line_editor.html#editing-mode).

::: tip
In Bash, history substitution occurs immediately after pressing <kbd>Enter</kbd>
to execute the command-line. Nushell, however, *inserts* the substitution into
the command-line after pressing <kbd>Enter</kbd>. This allows you to confirm
the substitution and, if needed, make additional edits before execution.

This behavior extends to "Edit command-line in Editor" as well. While Bash immediately
executes the command after exiting the editor, Nushell (like other, more modern shells
such as Fish and Zsh) inserts the editor contents into the command-line, allowing you
to review and make changes before committing it to execution.
:::