Home Explore Blog CI



nushell

4th chunk of `book/coming_from_bash.md`
8b6d2bf3e1df27a9797c8e3a7506f34909e8e36c3ee057970000000100000b06
| `<update ~/.bashrc>`                 | `vim $nu.config-path`                                         | Update environment variables permanently                          |
| `FOO=BAR ./bin`                      | `FOO=BAR ./bin`                                               | Update environment temporarily                                    |
| `export FOO=BAR`                     | `$env.FOO = BAR`                                              | Set environment variable for current session                      |
| `echo $FOO`                          | `$env.FOO`                                                    | Use environment variables                                         |
| `echo ${FOO:-fallback}`              | `$env.FOO? \| default "ABC"`                                  | Use a fallback in place of an unset variable                      |
| `unset FOO`                          | `hide-env FOO`                                                | Unset environment variable for current session                    |
| `alias s="git status -sb"`           | `alias s = git status -sb`                                    | Define an alias temporarily                                       |
| `type FOO`                           | `which FOO`                                                   | Display information about a command (builtin, alias, or executable) |
| `<update ~/.bashrc>`                 | `vim $nu.config-path`                                         | Add and edit alias permanently (for new shells)                   |
| `bash -c <commands>`                 | `nu -c <commands>`                                            | Run a pipeline of commands                                        |
| `bash <script file>`                 | `nu <script file>`                                            | Run a script file                                                 |
| `\`                                  | `( <command> )`                                               | A command can span multiple lines when wrapped with `(` and `)`   |
| `pwd` or `echo $PWD`                 | `pwd` or `$env.PWD`                                           | Display the current directory                                     |
| `read var`                           | `let var = input`                                             | Get input from the user                                           |
| `read -s secret`                     | `let secret = input -s`                                       | Get a secret value from the user without printing keystrokes      |

## History Substitutions and Default Keybindings:

| Bash                                 | Nu                                                            | Task                                                              |

Title: Bash to Nushell: Command Equivalents (Continued) and Shell Interactions
Summary
This section continues the comparison of Bash and Nushell commands, focusing on environment variable manipulation, alias creation, command information, script execution, multiline commands, working directory, and user input. It details Nushell equivalents for Bash commands like updating environment variables permanently and temporarily, setting and using environment variables, using fallbacks, unsetting variables, creating aliases, displaying command information using `type`, executing scripts, spanning commands across multiple lines, displaying the current directory, and getting user input (including secret input). The section then transitions to discussing history substitutions and default keybindings.