Skip to content

Nushell - Modern Structured Shell Cheatsheet

Nushell - Modern Structured Shell Cheatsheet

Section titled “Nushell - Modern Structured Shell Cheatsheet”

A modern shell that treats everything as structured data instead of raw text. Pipelines work with tables, records, and lists — not just strings. Think of it as a shell that understands JSON, CSV, TOML, and YAML natively.

PlatformCommand
macOS (Homebrew)brew install nushell
Windows (Winget)winget install nushell
Windows (Chocolatey)choco install nushell
Windows (Scoop)scoop install nu
Ubuntu/Debiansudo apt install nushell (or download from GitHub releases)
Arch Linuxsudo pacman -S nushell
Fedora/RHELsudo dnf install nushell
Cargo (All platforms)cargo install nu
Nixnix-env -iA nixpkgs.nushell

Launch: Run nu from any shell to start Nushell. Set as default shell: chsh -s $(which nu)

Nushell pipelines pass structured data (tables, records, lists), not text:

# Traditional shell: text → grep → awk → text
# Nushell: table → where → select → table

ls | where size > 1mb | sort-by size --reverse | first 5

Data types: strings, integers, floats, booleans, dates, durations, file sizes, lists, records, tables

CommandDescription
lsList directory as a structured table
ls -laList all files (including hidden) in long format
cd path/to/dirChange directory
cp source destCopy files or directories
mv source destMove or rename files
rm fileRemove files
mkdir dirnameCreate directory
open file.jsonOpen file as structured data (auto-detects format)
open file.csvOpen CSV as a table
open file.tomlOpen TOML as a record
save output.jsonSave pipeline output to file
cat file.txtDisplay file contents as text
psShow running processes as a table
sysShow system information
which commandFind command location
help commandsList all available commands
help <command>Show help for a specific command
CommandDescription
ls | where size > 10mbFilter files larger than 10 MB
ls | where name =~ "\.rs$"Filter by regex on filename
ls | where type == "dir"Show only directories
ls | where modified > 2dayFiles modified in last 2 days
ls | select name sizeShow only name and size columns
ls | reject typeRemove the type column
ls | get nameExtract just the name column as a list
ls | first 5Show first 5 entries
ls | last 3Show last 3 entries
ls | skip 10Skip first 10 entries
ls | nth 0 2 4Select entries by index
ls | lengthCount number of entries
ls | uniqRemove duplicate entries
CommandDescription
ls | sort-by sizeSort by size ascending
ls | sort-by size --reverseSort by size descending
ls | sort-by nameSort alphabetically
ls | group-by typeGroup entries by type
ls | group-by {get name | path parse | get extension}Group by file extension
CommandDescription
"hello world" | str upcaseConvert to uppercase
"HELLO" | str downcaseConvert to lowercase
" hello " | str trimTrim whitespace
"hello" | str contains "ell"Check if string contains substring
"hello" | str replace "l" "L"Replace characters
"hello world" | split row " "Split string into list
["hello" "world"] | str join ", "Join list into string
"hello" | str lengthGet string length
"hello" | str starts-with "he"Check string prefix
CommandDescription
open data.json | get field_nameAccess a field in JSON
open data.json | get nested.fieldAccess nested fields
{name: "Alice", age: 30}Create a record
[1 2 3 4 5]Create a list
[[name age]; [Alice 30] [Bob 25]]Create a table
$data | to jsonConvert to JSON
$data | to csvConvert to CSV
$data | to tomlConvert to TOML
$data | to yamlConvert to YAML
$data | to mdConvert to Markdown table
CommandDescription
[1 2 3 4] | math sumSum of values
[1 2 3 4] | math avgAverage of values
[1 2 3 4] | math maxMaximum value
[1 2 3 4] | math minMinimum value
[1 2 3 4] | math medianMedian value
ls | get size | math sumTotal size of listed files
1 + 2Basic arithmetic
10 / 3Division
2 ** 8Exponentiation
CommandDescription
http get https://api.example.com/dataFetch URL and parse response
http post https://api.example.com/data {key: "value"}POST request with body
fetch url | get fieldFetch and extract specific field
# Variables (immutable by default)
let name = "Alice"
let count = 42
let files = (ls | where size > 1mb)

# Mutable variables
mut counter = 0
$counter += 1

# If/else
if $count > 10 { "big" } else { "small" }

# Loops
for file in (ls) { print $file.name }
ls | each { |row| $row.name | str upcase }

# Custom commands (functions)
def greet [name: string] { $"Hello, ($name)!" }
greet "World"
FilePurpose
$nu.config-pathMain configuration (config.nu)
$nu.env-pathEnvironment configuration (env.nu)
# Show config file location
$nu.config-path

# Edit config
config nu    # Open config.nu in editor
config env   # Open env.nu in editor
# In config.nu
$env.config = {
    show_banner: false           # Disable welcome banner
    table: {
        mode: rounded            # Table style: rounded, compact, thin, none
    }
    completions: {
        algorithm: "fuzzy"       # Fuzzy tab completion
    }
    history: {
        max_size: 10000          # History entries to keep
        file_format: "sqlite"    # sqlite or plaintext
    }
}
# Find largest files in a project
ls **/* | where type == "file" | sort-by size --reverse | first 20

# Parse and query JSON API
http get https://api.github.com/repos/nushell/nushell | select stargazers_count forks_count

# Convert between formats
open data.csv | to json | save data.json

# Analyze log files
open access.log | lines | parse "{ip} - - [{date}] \"{method} {path} {proto}\" {status} {size}"
| where status == "404" | group-by path | sort-by -r

# Quick system overview
sys | get host
ps | sort-by cpu --reverse | first 10
FeatureBash/ZshNushell
Data modelText streamsStructured tables
Parsing outputgrep, awk, sedBuilt-in where, select, get
JSON handlingRequires jqNative (open file.json)
Error handlingExit codesRich error messages
Tab completionBasicContext-aware
Type systemNoneIntegers, strings, dates, sizes, etc.
Learning curveFamiliarNew syntax to learn
External commandsNativeFully supported