Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Introduction
  • Installation
    • Default Shell
  • Getting Started
    • Quick Tour
    • Moving Around the System
    • Thinking in Nu
    • Nushell Cheat Sheet
  • Nu Fundamentals
    • Types of Data
    • Loading Data
    • Pipelines
    • Working with Strings
    • Working with Lists
    • Working with Records
    • Working with Tables
    • Navigating and Accessing Structured Data
    • Special Variables
  • Programming in Nu
    • Custom Commands
    • Aliases
    • Operators
    • Variables
    • Control Flow
    • Scripts
    • Modules
      • Using Modules
      • Creating Modules
    • Overlays
    • Sorting
    • Testing your Nushell Code
    • Best Practices
  • Nu as a Shell
    • Configuration
    • Environment
    • Stdout, Stderr, and Exit Codes
    • Running System (External) Commands
    • How to Configure 3rd Party Prompts
    • Directory Stack
    • Reedline, Nu's Line Editor
    • Custom Completions
    • Externs
    • Coloring and Theming in Nu
    • Hooks
    • Background Jobs
  • Coming to Nu
    • Coming from Bash
    • Coming from CMD.EXE
    • Coming from PowerShell
    • Nu map from other shells and domain specific languages
    • Nu Map from Imperative Languages
    • Nu Map from Functional Languages
    • Nushell operator map
  • Design Notes
    • How Nushell Code Gets Run
  • (Not So) Advanced
    • Standard Library (Preview)
    • Dataframes
    • Metadata
    • Creating Your Own Errors
    • Parallelism
    • Plugins
    • explore

Running System (External) Commands

Nu provides a set of commands that you can use across different operating systems ("internal" commands) and having this consistency is helpful when creating cross-platform code. Sometimes, though, you want to run an external command that has the same name as an internal Nu command. To run the external ls or date command, for example, preface it with the caret (^) sigil. Prefacing with the caret calls the external command found in the user's PATH (e.g. /bin/ls) instead of Nu's internal ls command).

Nu internal command:

ls

External command (typically /usr/bin/ls):

^ls

Note

On Windows, ls is a PowerShell alias by default, so ^ls will not find a matching system command.

Passing Arguments

External arguments are separated by Nushell syntax, not by spaces inside a quoted string. Quote a string to keep its spaces inside one argument:

git commit -m "Update external command documentation"

Nushell does not automatically convert a list into external arguments, and passing a list directly produces an error. Use the spread operator (...) to pass each list item as its own argument:

let paths = ["file one.txt" "file two.txt"]
git add ...$paths

Here, git receives two path arguments, and the space in each path remains part of that argument. See the spread operator in command calls for more examples and the complete spreading rules.

The caret can also run an executable whose name or path is stored in a variable:

let program = "git"
^$program status

See Strings as external commands for the supported string forms. An extern declaration can add type checking and completions for a known external command; calling it follows the same argument rules described here.

Additional Windows Notes

When running an external command on Windows, Nushell forwards some CMD.EXE internal commands to cmd instead of attempting to run external commands. Coming from CMD.EXE contains a list of these commands and describes the behavior in more detail.

Edit this page on GitHub
Contributors: NotTheDr01ds, ColumbusLabs
Prev
Stdout, Stderr, and Exit Codes
Next
How to Configure 3rd Party Prompts